1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, 2002,
3 @c 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
14 To send an @dfn{e-mail} message in Emacs, type @kbd{C-x m}. This
15 selects and initializes a buffer named @samp{*mail*}, where you can
16 edit the text and headers of the message. Finally, type @kbd{C-c C-s}
17 or @kbd{C-c C-c} to send the message.
21 Begin composing mail (@code{compose-mail}).
23 Likewise, in another window (@code{compose-mail-other-window}).
25 Likewise, but in a new frame (@code{compose-mail-other-frame}).
27 In the mail buffer, send the message (@code{message-send}).
29 In the mail buffer, send the message and bury the buffer
30 (@code{message-send-and-exit}).
34 @findex compose-mail-other-window
36 @findex compose-mail-other-frame
38 The command @kbd{C-x 4 m} (@code{compose-mail-other-window}) does the
39 same as @kbd{C-x m}, except it displays the mail buffer in a different
40 window. The command @kbd{C-x 5 m} (@code{compose-mail-other-frame})
41 creates a new frame for the mail buffer.
43 Because the mail buffer is an ordinary Emacs buffer, you can switch
44 to other buffers while in the middle of composing mail, and switch
45 back later (or never). If you type @kbd{C-x m} again when you have
46 been composing another message but have not sent it, Emacs asks for
47 confirmation before erasing the old message. If you answer @kbd{n},
48 Emacs selects the mail buffer with its old contents, so you can finish
49 the old message and send it. @kbd{C-u C-x m} is another way to do
50 this. Sending the message marks the mail buffer ``unmodified,'' which
51 avoids the need for confirmation when @kbd{C-x m} is next used.
53 If you want to send another message before finishing the current
54 message, use the command @kbd{M-x rename-uniquely} to rename the
55 current mail buffer (@pxref{Misc Buffer}). Then you can use @kbd{C-x
56 m} to make a new mail buffer, and work with each mail buffer
60 * Format: Mail Format. Format of a mail message.
61 * Headers: Mail Headers. Details of some standard mail header fields.
62 * Aliases: Mail Aliases. Abbreviating and grouping mail addresses.
63 * Commands: Mail Commands. Special commands for editing mail being composed.
64 * Signature: Mail Signature. Adding a signature to every message.
65 * Amuse: Mail Amusements. Distracting the NSA; adding fortune messages.
66 * Methods: Mail Methods. Using alternative mail-composition methods.
70 @section The Format of the Mail Buffer
72 An email message must contain certain pieces of information, called
73 @dfn{headers}, which specify the message's sender, recipient(s), and
76 At the top of the mail buffer is a set of @dfn{header fields}, where
77 you can enter this information. You can insert and edit header fields
78 using ordinary editing commands. @xref{Header Editing}, for commands
79 specific to editing header fields.
81 Some header fields are automatically pre-initialized in the buffer,
82 when appropriate; other headers, such as @samp{Date} and
83 @samp{Message-Id}, are normally omitted from the mail buffer and
84 created automatically when the message is sent.
86 @vindex mail-header-separator
87 The line in the buffer that says
90 --text follows this line--
94 separates the header fields from the @dfn{body} (or @dfn{text}) of the
95 message. Everything above this line is treated as part of the
96 headers; everything below it is treated as the body. The delimiter
97 line itself does not appear in the message actually sent. The text
98 used for the delimiter line is controlled by the variable
99 @code{mail-header-separator}.
101 Here is an example of what the headers and text in the mail buffer
106 CC: lungfish@@example.com, byob@@example.net
107 Subject: The Emacs Manual
108 --text follows this line--
109 Please ignore this message.
113 @section Mail Header Fields
114 @cindex headers (of mail message)
116 A header field in the mail buffer starts with a field name at the
117 beginning of a line, terminated by a colon. Upper and lower case are
118 equivalent in field names (and in mailing addresses also). After the
119 colon and optional whitespace comes the contents of the field.
121 You can use any name you like for a header field, but normally
122 people use only standard field names with accepted meanings. Here is
123 a table of commonly-used fields. Emacs pre-initializes some of these,
124 depending on various options you can set. You can delete or alter any
125 header field before you send the message, if you wish.
129 @vindex user-mail-address
130 The address of the sender (you). This should be a valid mailing
131 address, as replies will normally go there. Emacs initializes this
132 field using the variables @code{user-full-name} and
133 @code{user-mail-address}; see below.
136 The mailing address(es) to which the message is addressed. To list
137 more than one address, use commas (not spaces) to separate them.
140 A piece of text saying what the message is about. Most mail-reading
141 programs can display a summary of messages, listing the subject of
142 each message but not its text.
145 Additional mailing address(es) to send the message to. This is like
146 @samp{To}, except that these readers should not regard the message as
150 Additional mailing address(es) to send the message to, which should
151 not appear in the header of the message actually sent. ``BCC'' stands
152 for @dfn{blind carbon copies}.
155 The name of one file, to which a copy of the sent message should be
156 appended. Emacs writes the message in mbox format, unless the file is
157 in Babyl format (used by Rmail before Emacs 23), in which case Emacs
158 writes Babyl. If an Rmail buffer is visiting the file, Emacs updates
159 it accordingly. To specify more than one file, use several @samp{FCC}
160 fields, with one file name in each field.
163 An address to which replies should be sent, instead of @samp{From}.
164 You can use this header if, for some reason, your @samp{From} address
165 is unable to receive replies.
168 This field takes precedence over @samp{Reply-to}. It is used because
169 some mailing lists set the @samp{Reply-to} field for their own purposes
170 (a somewhat controversial practice).
172 @item Mail-followup-to
173 This field contains one or more addresses. It is typically used when
174 you reply to a message from a mailing list that you are subscribed to.
175 It usually indicates that you want replies to go to the list, and that
176 you do not need an extra copy sent directly to you.
178 @c Message mode handles this differently...
179 @c @vindex mail-mailing-lists
180 @c The variable @code{mail-mailing-lists} holds a list of mailing list
181 @c addresses that you are subscribed to. If it is non-@code{nil}, Emacs
182 @c inserts an appropriate @samp{Mail-followup-to} header when sending mail
183 @c to a mailing list.
186 A piece of text describing the message you are replying to. Some mail
187 systems can use this information to correlate related pieces of mail.
188 Normally, you never need to think about this, because it is filled in
189 automatically when you reply to a message in Rmail (or any other mail
190 program built into Emacs).
193 The Message-Ids of previous related messages (a Message-Id is a unique
194 identifier generated when a message is sent). Like
195 @samp{In-reply-to}, this is normally set up automatically for you.
199 The @samp{To}, @samp{CC}, and @samp{BCC} fields can appear any number
200 of times, and each such header field can contain multiple addresses,
201 separated by commas. This way, you can specify any number of places
202 to send the message. These fields can also have continuation lines:
203 one or more lines starting with whitespace, following the starting
204 line of the field, are considered part of the field. Here's an
205 example of a @samp{To} field with a continuation line:
209 To: foo@@example.net, this@@example.net,
214 @vindex user-full-name
215 @vindex user-mail-address
216 The default contents of the @samp{From} header field are computed
217 from the variables @code{user-full-name} and @code{user-mail-address}.
218 On some operating systems, Emacs initializes these two variables using
219 environment variables (@pxref{General Variables}). If this
220 information is unavailable or wrong, you can customize the variables
221 yourself (@pxref{Easy Customization}).
223 @vindex mail-from-style
224 The value of the variable @code{mail-from-style} specifies how to
225 format the address in the @samp{From} field:
229 Use just the address, as in @samp{king@@grassland.com}.
231 Use both address and full name, as in:@*
232 @samp{king@@grassland.com (Elvis Parsley)}.
234 Use both address and full name, as in:@*
235 @samp{Elvis Parsley <king@@grassland.com>}.
236 @item any other value
237 Use @code{angles} for most addresses. However, if the address must be
238 ``quoted'' to remain syntactically-valid under the @code{angles}
239 format but not under the @code{parens} format, use @code{parens}
240 instead. This is the default.
243 @c There is also mail-specify-envelope-from and mail-envelope-from, but
244 @c these are probably not topics for the Emacs manual.
246 @vindex mail-default-headers
247 You can direct Emacs to insert certain default headers into the mail
248 buffer by setting the variable @code{mail-default-headers} to a
249 string. Then @kbd{C-x m} inserts this string into the message
250 headers. For example, here is how to add a @samp{Reply-to} and
251 @samp{FCC} header to each message:
254 (setq mail-default-headers
255 "Reply-to: foo@@example.com\nFCC: ~/Mail/sent")
259 If the default header fields are not appropriate for a
260 particular message, edit them as necessary before sending the message.
263 @section Mail Aliases
265 @cindex @file{.mailrc} file
267 @vindex mail-personal-alias-file
269 You can define @dfn{mail aliases}, which are short mnemonic names
270 that stand for mail addresses or groups of mail addresses. By
271 default, mail aliases are defined in the file @file{~/.mailrc}. You
272 can specify a different file name to use, by setting the variable
273 @code{mail-personal-alias-file}.
275 To define an alias in @file{.mailrc}, write a line in the following
279 alias @var{nick} @var{fulladdresses}
283 This means that @var{nick} should expand into @var{fulladdresses},
284 where @var{fulladdresses} can be either a single address, or multiple
285 addresses separated with spaces. For instance, to make @code{maingnu}
286 stand for @code{gnu@@gnu.org} plus a local address of your own, put in
290 alias maingnu gnu@@gnu.org local-gnu
294 If an address contains a space, quote the whole address with a pair of
295 double quotes, like this:
298 alias jsmith "John Q. Smith <none@@example.com>"
302 Note that you need not include double quotes around individual parts
303 of the address, such as the person's full name. Emacs puts them in if
304 they are needed. For instance, it inserts the above address as
305 @samp{"John Q. Smith" <none@@example.com>}.
307 Emacs also recognizes ``include'' commands in @file{.mailrc}. They
311 source @var{filename}
315 The @file{.mailrc} file is not unique to Emacs; many other
316 mail-reading programs use it for mail aliases, and it can contain
317 various other commands. However, Emacs ignores everything except
318 alias definitions and include commands.
320 @findex mail-abbrev-insert-alias
321 Mail aliases expand as abbrevs---that is to say, as soon as you type
322 a word-separator character after an alias (@pxref{Abbrevs}). This
323 expansion takes place only within the @samp{To}, @samp{From},
324 @samp{CC}, @samp{BCC}, and @samp{Reply-to} header fields (plus their
325 @samp{Resent-} variants); it does not take place in other header
326 fields, such as @samp{Subject}.
328 You can also insert an aliased address directly, using the command
329 @kbd{M-x mail-abbrev-insert-alias}. This reads an alias name, with
330 completion, and inserts its definition at point.
333 @section Mail Commands
335 @cindex mode, Message
337 The default major mode for the @samp{*mail*} buffer is called
338 Message mode. It behaves like Text mode in many ways, but provides
339 several additional commands on the @kbd{C-c} prefix, which make
340 editing a message more convenient.
342 In this section, we will describe some of the most commonly-used
343 commands available in Message mode.
345 Message mode also has its own manual, where its features are described
346 in greater detail. @xref{Top,,Message, message, Message}.
350 * Mail Sending:: Commands to send the message.
351 * Header Editing:: Commands to move to header fields and edit them.
352 * Citing Mail:: Quoting a message you are replying to.
353 * Mail Misc:: Attachments, spell checking, etc.
357 @subsection Mail Sending
359 There are two commands to send a message you have been editing:
363 Send the message, and deselect the mail buffer (@code{message-send-and-exit}).
365 Send the message, and leave the mail buffer selected (@code{message-send}).
368 @kindex C-c C-s @r{(Message mode)}
369 @kindex C-c C-c @r{(Message mode)}
371 If you want to send a message and be done with it, type @kbd{C-c
372 C-c} (@code{mail-send-and-exit}). This sends the message and then
373 either deletes the window or switches to another buffer. It also
374 ``buries'' the mail buffer, putting it at the lowest priority for
375 reselection. This is the usual command for sending a message.
377 @findex message-send-and-exit
378 The command @kbd{C-c C-s} (@code{message-send}) sends the message
379 and marks the mail buffer unmodified, but leaves the buffer selected.
380 Use this command if you want to modify the message (perhaps with new
381 recipients) and send it again.
383 @vindex message-send-hook
384 Sending a message runs the hook @code{message-send-hook}.
386 In a file-visiting buffer, sending the message does not clear the
387 modified flag, because only saving the file should do that. Also, you
388 don't get a warning if you try to send the same message twice.
390 @vindex sendmail-coding-system
391 When you send a message containing non-@acronym{ASCII} characters,
392 they need to be encoded with a coding system (@pxref{Coding Systems}).
393 Usually the coding system is specified automatically by your chosen
394 language environment (@pxref{Language Environments}). You can
395 explicitly specify the coding system for outgoing mail by setting the
396 variable @code{sendmail-coding-system} (@pxref{Recognize Coding}). If
397 the coding system thus determined does not handle the characters in a
398 particular message, Emacs asks you to select the coding system to use,
399 showing a list of possible coding systems.
405 @vindex send-mail-function
406 The variable @code{send-mail-function} controls how the default mail
407 user agent sends mail. It should be set to a function. In most
408 cases, the default is @code{sendmail-send-it}, which delivers mail
409 using @command{sendmail} (or a @command{sendmail}-compatible program).
410 On Mac OS X and MS-Windows, however, the default is normally
411 @code{mailclient-send-it}, which passes the mail buffer on to the
412 system's designated mail client (see @file{mailclient.el}). To send
413 mail through an SMTP server, set @code{send-mail-function} to
414 @code{smtpmail-send-it} and set up the Emacs SMTP library
415 (@pxref{Top,,Emacs SMTP Library, smtpmail, Sending mail via SMTP}).
416 Another option is @code{feedmail-send-it} (see the commentary section
417 of the @file{feedmail.el} package).
420 @subsection Mail Header Editing
422 Message mode provides the following special commands to move to
423 particular header fields and to complete addresses in headers.
427 Move to the @samp{To} header (@code{message-goto-to}).
429 Move to the @samp{Subject} header (@code{message-goto-subject}).
431 Move to the @samp{CC} header (@code{message-goto-cc}).
433 Move to the @samp{BCC} header (@code{message-goto-bcc}).
435 Move to the @samp{Reply-To} header (@code{message-goto-reply-to}).
437 Move to the @samp{Mail-Followup-To} header field
438 (@code{message-goto-followup-to}).
440 Add a new @samp{FCC} header field, with file-name completion
441 (@code{message-goto-fcc}).
443 Move to the start of the message body (@code{message-goto-body}).
445 Complete a mailing address (@code{message-tab}).
448 @kindex C-c C-f C-t @r{(Message mode)}
449 @findex message-goto-to
450 @kindex C-c C-f C-s @r{(Message mode)}
451 @findex message-goto-subject
452 @kindex C-c C-f C-c @r{(Message mode)}
453 @findex message-goto-cc
454 @kindex C-c C-f C-b @r{(Message mode)}
455 @findex message-goto-bcc
456 @kindex C-c C-f C-r @r{(Message mode)}
457 @findex goto-reply-to
458 @kindex C-c C-f C-f @r{(Message mode)}
459 @findex goto-followup-to
460 @kindex C-c C-f C-w @r{(Message mode)}
461 @findex message-goto-fcc
462 The commands to move point to particular header fields are all based
463 on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field''). If the
464 field in question does not exist, the command creates one (the
465 exception is @code{mail-fcc}, which creates a new field each time).
467 @kindex C-c C-b @r{(Message mode)}
469 The command @kbd{C-c C-b} (@code{message-goto-body}) moves point to
470 just after the header separator line---that is, to the beginning of
474 @kindex TAB @r{(Message mode)}
475 While editing a header field that contains addresses, such as
476 @samp{To:}, @samp{CC:} and @samp{BCC:}, you can complete an address by
477 typing @key{TAB} (@code{message-tab}). This attempts to insert the
478 full name corresponding to the address based on a couple of methods,
479 including EUDC, a library that recognizes a number of directory server
480 protocols (@pxref{Top,,EUDC,eudc, The Emacs Unified Directory
481 Client}). Failing that, it attempts to expand the address as a mail
482 alias (@pxref{Mail Aliases}). If point is on a header field that does
483 not take addresses, or if it is in the message body, then @key{TAB}
484 just inserts a tab character.
487 @subsection Citing Mail
492 Yank the selected message from Rmail (@code{message-yank-original}).
494 Fill each paragraph cited from another message
495 (@code{message-fill-yanked-message}).
498 @kindex C-c C-y @r{(Message mode)}
499 @findex message-yank-original
500 @findex message-yank-prefix
501 You can use the command @kbd{C-c C-y} (@code{message-yank-original})
502 to @dfn{cite} a message that you are replying to. This inserts the
503 text of that message into the mail buffer. This command is active
504 only when the mail buffer is invoked from a mail program running in
505 Emacs, such as Rmail.
507 By default, Emacs inserts the string @samp{>} in front of each line
508 of the cited text; this prefix string is specified by the variable
509 @code{message-yank-prefix}. If you call @code{message-yank-original}
510 with a prefix argument, the citation prefix is not inserted.
512 @kindex C-c C-q @r{(Message mode)}
513 @findex mail-fill-yanked-message
514 After using @kbd{C-c C-y}, you can type @kbd{C-c C-q}
515 (@code{message-fill-yanked-message}) to fill the paragraphs of the
516 cited message. One use of @kbd{C-c C-q} fills all such paragraphs,
517 each one individually. To fill a single paragraph of the quoted
518 message, use @kbd{M-q}. If filling does not automatically handle the
519 type of citation prefix you use, try setting the fill prefix
520 explicitly. @xref{Filling}.
522 @vindex mail-citation-hook
523 You can customize mail citation through the hook
524 @code{mail-citation-hook}. For example, you can use the Supercite
525 package, which provides more flexible citation
526 (@pxref{Introduction,,,sc, Supercite}).
529 @subsection Mail Miscellany
531 @kindex C-c C-a @r{(Message mode)}
532 @findex mail-attach-file
534 @cindex Multipurpose Internet Mail Extensions
535 You can @dfn{attach} a file to an outgoing message by typing
536 @kbd{C-c C-a} (@code{mml-attach-file}) in the mail buffer. Attaching
537 is done using the MIME (Multipurpose Internet Mail Extensions)
540 The @code{mml-attach-file} command prompts for the name of the file,
541 and for the attachment's @dfn{content type}, @dfn{description}, and
542 @dfn{disposition}. The content type is normally detected
543 automatically; just type @key{RET} to accept the default. The
544 description is a single line of text that the recipient will see next
545 to the attachment; you may also choose to leave this empty. The
546 disposition is either @samp{inline} (the default), which means the
547 recipient will see a link to the attachment within the message body,
548 or @samp{attachment}, which means the link will be separate from the
551 The actual contents of the attached file are not inserted into the
552 mail buffer. Instead, some placeholder text is inserted into the mail
556 <#part type="text/plain" filename="~/foo.txt" disposition=inline>
561 When you type @kbd{C-c C-c} or @kbd{C-c C-s} to send the message, the
562 attached file will be delivered with it.
564 @findex ispell-message
565 While composing a message, you can do spelling correction on the
566 message text by typing @kbd{M-x ispell-message}. If you have yanked
567 an incoming message into the outgoing draft, this command skips what
568 was yanked, but it checks the text that you yourself inserted (it
569 looks for indentation or @code{mail-yank-prefix} to distinguish the
570 cited lines from your input). @xref{Spelling}.
572 @vindex mail-mode-hook
573 @vindex mail-setup-hook
574 Turning on Message mode (which @kbd{C-x m} does automatically) runs
575 the normal hooks @code{text-mode-hook} and @code{message-mode-hook}.
576 Initializing a new outgoing message runs the normal hook
577 @code{message-setup-hook}; you can use this hook if you want to make
578 changes to the appearance of the mail buffer. @xref{Hooks}.
580 The main difference between these hooks is just when they are
581 invoked. Whenever you type @kbd{C-x m}, @code{message-mode-hook} runs
582 as soon as the mail buffer is created. Then the @code{message-setup}
583 function inserts the default contents of the buffer. After these
584 default contents are inserted, @code{message-setup-hook} runs.
586 If you use @kbd{C-x m} to continue an existing composition,
587 @code{message-mode-hook} runs immediately after switching to the mail
588 buffer. If the buffer is unmodified, or if you decide to erase it and
589 start again, @code{message-setup-hook} runs after the default contents
593 @section Mail Signature
595 @cindex mail signature
596 @vindex mail-signature-file
597 @vindex mail-signature
598 You can add a standard piece of text---your @dfn{mail
599 signature}---to the end of every message. This signature may contain
600 information such as your telephone number or your physical location.
601 The variable @code{mail-signature} determines how Emacs handles the
604 The default value of @code{mail-signature} is @code{t}; this means
605 to look for your mail signature in the file @file{~/.signature}. If
606 this file exists, its contents are automatically inserted into the end
607 of the mail buffer. You can change the signature file via the
608 variable @code{mail-signature-file}.
610 If you change @code{mail-signature} to a string, that specifies the
611 text of the signature directly.
613 @kindex C-c C-w @r{(Message mode)}
614 @findex message-insert-signature
615 If you change @code{mail-signature} to @code{nil}, Emacs will not
616 insert your mail signature automatically. You can insert your mail
617 signature by typing @kbd{C-c C-w} (@code{message-insert-signature}) in
618 the mail buffer. Emacs will look for your signature in the signature
621 By convention, a mail signature should be marked by a line whose
622 contents are @samp{-- }. If your signature lacks this prefix, it is
623 added for you. The remainder of your signature should be no more than
626 @node Mail Amusements
627 @section Mail Amusements
631 @kbd{M-x spook} adds a line of randomly chosen keywords to an outgoing
632 mail message. The keywords are chosen from a list of words that suggest
633 you are discussing something subversive.
635 The idea behind this feature is the suspicion that the
636 NSA@footnote{The US National Security Agency.} and other intelligence
637 agencies snoop on all electronic mail messages that contain keywords
638 suggesting they might find them interesting. (The agencies say that
639 they don't, but that's what they @emph{would} say.) The idea is that if
640 lots of people add suspicious words to their messages, the agencies will
641 get so busy with spurious input that they will have to give up reading
642 it all. Whether or not this is true, it at least amuses some people.
644 @findex fortune-to-signature
645 @cindex fortune cookies
646 You can use the @code{fortune} program to put a ``fortune cookie''
647 message into outgoing mail. To do this, add
648 @code{fortune-to-signature} to @code{mail-setup-hook}:
651 (add-hook 'mail-setup-hook 'fortune-to-signature)
655 You will probably need to set the variable @code{fortune-file} before
659 @section Mail-Composition Methods
660 @cindex mail-composition methods
664 @cindex MH mail interface
665 @cindex Message mode for sending mail
666 In this chapter we have described the usual Emacs mode for editing
667 and sending mail---Message mode. This is only one of several
668 available modes. Prior to Emacs 23.2, the default mode was Mail mode,
669 which is similar to Message mode in many respects but lacks features
670 such as MIME support. Another available mode is MH-E
671 (@pxref{Top,,MH-E,mh-e, The Emacs Interface to MH}).
673 @vindex mail-user-agent
674 You can choose any of these @dfn{mail user agents} as your preferred
675 method for editing and sending mail. The commands @code{C-x m},
676 @code{C-x 4 m} and @code{C-x 5 m} use whichever agent you have
677 specified; so do various other parts of Emacs that send mail, such as
678 the bug reporter (@pxref{Bugs}). To specify a mail user agent,
679 customize the variable @code{mail-user-agent}. Currently, legitimate
680 values include @code{message-user-agent} (Message mode)
681 @code{sendmail-user-agent} (Mail mode), @code{gnus-user-agent}, and
682 @code{mh-e-user-agent}.
684 If you select a different mail-composition method, the information
685 in this chapter about the mail buffer and Message mode does not apply;
686 the other methods use a different format of text in a different
687 buffer, and their commands are different as well.
689 @vindex read-mail-command
690 Similarly, to specify your preferred method for reading mail,
691 customize the variable @code{read-mail-command}. The default is
692 @code{rmail} (@pxref{Rmail}).
695 arch-tag: d8a3dfc3-5d87-45c5-a7f2-69871b8e4fd6