Go to the previous, next section.
To send a message in Emacs, you start by typing a command (C-x m) to select and initialize the `*mail*' buffer. Then you edit the text and headers of the message in this buffer, and type another command (C-c C-c) to send the message.
mail).
mail-other-window).
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 mail composition buffer 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, you are asked to confirm before the old message is erased. If you answer n, the `*mail*' buffer is left selected with its old contents, so you can finish the old message and send it. C-u C-x m is another way to do this. Sending the message marks the `*mail*' buffer "unmodified", which avoids the need for confirmation when C-x m is next used.
If you are composing a message in the `*mail*' buffer and want to send another message before finishing the first, rename the `*mail*' buffer using M-x rename-buffer (see section Miscellaneous Buffer Operations).
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 Emacs Manual --Text follows this line-- Please ignore this message.
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.
If you set the variable mail-default-reply-to to a non-nil
value, then every message you begin to edit will have a `Reply-to'
field whose contents are the value of the variable.
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 will scan it for mail aliases the first time you try to send mail in an Emacs session. Aliases found in the `To', `CC', and `BCC' fields will be expanded where appropriate.
If the variable mail-archive-file-name is non-nil, it should be a
string naming a file; every time you start to edit a message to send,
an `FCC' field will be put in for that file. Unless you remove the
`FCC' field, every message will be written into that file when it is
sent.
The major mode used in the `*mail*' buffer is Mail mode, which is much like Text mode except that various special commands are provided on the C-c prefix. These commands all have to do specifically with editing or sending the message.
mail-send).
mail-send-and-exit).
mail-to).
mail-subject).
mail-cc).
mail-signature).
mail-yank-original).
This command does nothing unless your command to start sending a
message was issued with Rmail.
mail-fill-yanked-message).
There are two ways to send the message. 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. C-c C-c (mail-send-and-exit)
sends 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. This is
the usual way to send the message.
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 the most common fields for the
user to want to edit.
C-c C-w (mail-signature) adds a standard piece 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 mail sending is invoked from the Rmail mail reader using an Rmail command, C-c C-y can be used inside the `*mail*' buffer to insert the text of the message you are replying to. Normally it 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 type
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.
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. Aside from these, the mail command runs
mail-setup-hook whenever it initializes the `*mail*' buffer
for editing a message.
Go to the previous, next section.