[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25. Sending Mail

To send a message in Emacs, start by typing the command (C-x m) to select and initialize the `*mail*' buffer. You can then edit the text and headers of the message in the mail buffer, and type the command (C-c C-c) to send the message.

C-x m
Begin composing a message to send (mail).
C-x 4 m
Likewise, but display the message in another window (mail-other-window).
C-c C-c
In Mail mode, send the message and switch to another buffer (mail-send-and-exit).

The command C-x m (mail) selects a buffer named `*mail*' and initializes it with the skeleton of an outgoing message. C-x 4 m (mail-other-window) selects the `*mail*' buffer in a different window, leaving the previous current buffer visible.

Because the buffer for mail composition is an ordinary Emacs buffer, you can switch to other buffers while in the middle of composing mail, and switch back later (or never). If you use the C-x m command again when you have been composing another message but have not sent it, a new mail buffer will be created; in this way, you can compose multiple messages at once. You can switch back to and complete an unsent message by using the normal buffer selection mechanisms.

C-u C-x m is another way to switch back to a message in progress: it will search for an existing, unsent mail message buffer and select it.

Beware that this email client was inherited from GNU Emacs and is very underfeatured; its support for MIME attachments and writing non-ASCII content to files without trashing data is weak to nonexistent. There exist excellent, full-featured email clients in See section 22.8 Packages, notably VM @xref{(vm)} and Gnus @xref{(gnus)}---the XEmacs developers recommend that you choose one of them, and at most use this mail client for reporting simple bugs, the reason we include it.

25.1 The Format of the Mail Buffer  Format of the mail being composed.
25.2 Mail Header Fields  Details of allowed mail header fields.
25.3 Mail Mode  Special commands for editing mail being composed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25.1 The Format of the Mail Buffer

In addition to the text or contents, a message has header fields, which say who sent it, when, to whom, why, and so on. Some header fields, such as the date and sender, are created automatically after the message is sent. Others, such as the recipient names, must be specified by you in order to send the message properly.

Mail mode provides a few commands to help you edit some header fields, and some are preinitialized in the buffer automatically at times. You can insert or edit any header fields using ordinary editing commands.

The line in the buffer that says:

 
--text follows this line--

is a special delimiter that separates the headers you have specified from the text. Whatever follows this line is the text of the message; the headers precede it. The delimiter line itself does not appear in the message actually sent. The text used for the delimiter line is controlled by the variable mail-header-separator.

Here is an example of what the headers and text in the `*mail*' buffer might look like.

 
To: rms@mc
CC: mly@mc, rg@oz
Subject: The XEmacs User's Manual
--Text follows this line--
Please ignore this message.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25.2 Mail Header Fields

There are several header fields you can use in the `*mail*' buffer. Each header field starts with a field name at the beginning of a line, terminated by a colon. It does not matter whether you use upper or lower case in the field name. After the colon and optional whitespace comes the contents of the field.

`To'
This field contains the mailing addresses of the message.

`Subject'
The contents of the `Subject' field should be a piece of text that says what the message is about. Subject fields are useful because most mail-reading programs can provide a summary of messages, listing the subject of each message but not its text.

`CC'
This field contains additional mailing addresses to send the message to, but whose readers should not regard the message as addressed to them.

`BCC'
This field contains additional mailing addresses to send the message to, but which should not appear in the header of the message actually sent.

`FCC'
This field contains the name of one file (in Unix mail file format) to which a copy of the message should be appended when the message is sent.

`From'
Use the `From' field to say who you are, when the account you are using to send the mail is not your own. The contents of the `From' field should be a valid mailing address, since replies will normally go there.

`Reply-To'
Use the `Reply-To' field to direct replies to a different address, not your own. `From' and `Reply-To' have the same effect on where replies go, but they convey a different meaning to the person who reads the message.

`In-Reply-To'
This field contains a piece of text describing a message you are replying to. Some mail systems can use the information to correlate related pieces of mail. This field is normally filled in by your mail handling package when you are replying to a message and you never need to think about it.

The `To', `CC', `BCC' and `FCC' fields can appear any number of times, to specify many places to send the message.

The `To', `CC', and `BCC', fields can have continuation lines. All the lines starting with whitespace, following the line on which the field starts, are considered part of the field. For example,

 
To: foo@here, this@there,
  me@gnu.cambridge.mass.usa.earth.spiral3281

If you have a `~/.mailrc' file, Emacs scans it for mail aliases the first time you try to send mail in an Emacs session. Emacs expands aliases found in the `To', `CC', and `BCC' fields where appropriate. You can set the variable mail-abbrev-mailrc-file to the name of the file with mail aliases. If nil, `~/.mailrc' is used.

Your `.mailrc' file ensures that word-abbrevs are defined for each of your mail aliases when point is in a `To', `CC', `BCC', or `From' field. The aliases are defined in your `.mailrc' file or in a file specified by the MAILRC environment variable if it exists. Your mail aliases expand any time you type a word-delimiter at the end of an abbreviation.

In this version of Emacs, what you see is what you get: in contrast to some other versions, no abbreviations are expanded after you have sent the mail. This means you don't suffer the annoyance of having the system do things behind your back--if the system rewrites an address you typed, you know it immediately, instead of after the mail has been sent and it's too late to do anything about it. For example, you will never again be in trouble because you forgot to delete an old alias from your `.mailrc' and a new local user is given a userid which conflicts with one of your aliases.

Your mail alias abbrevs are in effect only when point is in an appropriate header field. The mail aliases will not expand in the body of the message, or in other header fields. The default mode-specific abbrev table mail-mode-abbrev-table is used instead if defined. That means if you have been using mail-mode specific abbrevs, this code will not adversely affect you. You can control which header fields the abbrevs are used in by changing the variable mail-abbrev-mode-regexp.

If auto-fill mode is on, abbrevs wrap at commas instead of at word boundaries, and header continuation lines will be properly indented.

You can also insert a mail alias with mail-interactive-insert-alias. This function, which is bound to C-c C-a, prompts you for an alias (with completion) and inserts its expansion at point.

In this version of Emacs, it is possible to have lines like the following in your `.mailrc' file:

 
     alias someone "John Doe <doe@quux.com>"

That is, if you want an address to have embedded spaces, simply surround it with double-quotes. The quotes are necessary because the format of the `.mailrc' file uses spaces as address delimiters.

Aliases in the `.mailrc' file may be nested. For example, assume you define aliases like:

 
     alias group1 fred ethel
     alias group2 larry curly moe
     alias everybody group1 group2

When you now type `everybody' on the `To' line, it will expand to:

 
     fred, ethyl, larry, curly, moe

Aliases may contain forward references; the alias of `everybody' in the example above can precede the aliases of `group1' and `group2'.

In this version of Emacs, you can use the source `.mailrc' command for reading aliases from some other file as well.

Aliases may contain hyphens, as in "alias foo-bar foo@bar", even though word-abbrevs normally cannot contain hyphens.

To read in the contents of another `.mailrc'-type file from Emacs, use the command M-x merge-mail-aliases. The rebuild-mail-aliases command is similar, but deletes existing aliases first.

If you want multiple addresses separated by a string other than `,' (a comma), then set the variable mail-alias-separator-string to it. This has to be a comma bracketed by whitespace if you want any kind of reasonable behavior.

If the variable mail-archive-file-name is non-nil, it should be a string naming a file. Each time you start to edit a message to send, an `FCC' field is entered for that file. Unless you remove the `FCC' field, every message is written into that file when it is sent.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25.3 Mail Mode

The major mode used in the `*mail*' buffer is Mail mode. Mail mode is similar to Text mode, but several commands are provided on the C-c prefix. These commands all deal specifically with editing or sending the message.

C-c C-s
Send the message, and leave the `*mail*' buffer selected (mail-send).
C-c C-c
Send the message, and select some other buffer (mail-send-and-exit).
C-c C-f C-t
Move to the `To' header field, creating one if there is none (mail-to).
C-c C-f C-s
Move to the `Subject' header field, creating one if there is none (mail-subject).
C-c C-f C-c
Move to the `CC' header field, creating one if there is none (mail-cc).
C-c C-w
Insert the file `~/.signature' at the end of the message text (mail-signature).
C-c C-y
Yank the selected message (mail-yank-original).
C-c C-q
Fill all paragraphs of yanked old messages, each individually (mail-fill-yanked-message).
button3
Pops up a menu of useful mail-mode commands.

There are two ways to send a message. C-c C-c (mail-send-and-exit) is the usual way to send the message. It sends the message and then deletes the window (if there is another window) or switches to another buffer. It puts the `*mail*' buffer at the lowest priority for automatic reselection, since you are finished with using it. C-c C-s (mail-send) sends the message and marks the `*mail*' buffer unmodified, but leaves that buffer selected so that you can modify the message (perhaps with new recipients) and send it again.

Mail mode provides some other special commands that are useful for editing the headers and text of the message before you send it. There are three commands defined to move point to particular header fields, all based on the prefix C-c C-f (`C-f' is for "field"). They are C-c C-f C-t (mail-to) to move to the `To' field, C-c C-f C-s (mail-subject) for the `Subject' field, and C-c C-f C-c (mail-cc) for the `CC' field. These fields have special motion commands because they are edited most frequently.

C-c C-w (mail-signature) adds a standard piece of text at the end of the message to say more about who you are. The text comes from the file `.signature' in your home directory.

When you use an Rmail command to send mail from the Rmail mail reader, you can use C-c C-y mail-yank-original inside the `*mail*' buffer to insert the text of the message you are replying to. Normally Rmail indents each line of that message four spaces and eliminates most header fields. A numeric argument specifies the number of spaces to indent. An argument of just C-u says not to indent at all and not to eliminate anything. C-c C-y always uses the current message from the `RMAIL' buffer, so you can insert several old messages by selecting one in `RMAIL', switching to `*mail*' and yanking it, then switching back to `RMAIL' to select another.

After using C-c C-y, you can use the command C-c C-q (mail-fill-yanked-message) to fill the paragraphs of the yanked old message or messages. One use of C-c C-q fills all such paragraphs, each one separately.

Clicking the right mouse button in a mail buffer pops up a menu of the above commands, for easy access.

Turning on Mail mode (which C-x m does automatically) calls the value of text-mode-hook, if it is not void or nil, and then calls the value of mail-mode-hook if that is not void or nil.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on August, 3 2012 using texi2html