1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2013 Free Software
4 @c See file emacs.texi for copying conditions.
14 To send an email message from Emacs, type @kbd{C-x m}. This
15 switches to a buffer named @file{*unsent mail*}, where you can edit
16 the text and headers of the message. When done, type @kbd{C-c C-s} or
17 @kbd{C-c C-c} to send it.
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}).
33 The mail buffer is an ordinary Emacs buffer, so you can switch to
34 other buffers while composing the mail. If you want to send another
35 mail before finishing the current one, type @kbd{C-x m} again to open
36 a new mail buffer whose name has a different numeric suffix
37 (@pxref{Misc Buffer}). If you invoke the command with a prefix
38 argument, @w{@kbd{C-u C-x m}}, Emacs switches back to the last mail
39 buffer, and asks if you want to erase the message in that buffer; if
40 you answer no, this lets you pick up editing the message where you
44 @findex compose-mail-other-window
46 @findex compose-mail-other-frame
47 The command @kbd{C-x 4 m} (@code{compose-mail-other-window}) does
48 the same as @kbd{C-x m}, except it displays the mail buffer in a
49 different window. The command @kbd{C-x 5 m}
50 (@code{compose-mail-other-frame}) does it in a new frame.
52 When you type @kbd{C-c C-c} or @kbd{C-c C-s} to send the mail, Emacs
53 may ask you how it should deliver the mail---either directly via SMTP,
54 or using some other method. @xref{Mail Sending}, for details.
57 * Format: Mail Format. Format of a mail message.
58 * Headers: Mail Headers. Details of some standard mail header fields.
59 * Aliases: Mail Aliases. Abbreviating and grouping mail addresses.
60 * Commands: Mail Commands. Special commands for editing mail being composed.
61 * Signature: Mail Signature. Adding a signature to every message.
62 * Amuse: Mail Amusements. Distracting the NSA; adding fortune messages.
63 * Methods: Mail Methods. Using alternative mail-composition methods.
67 @section The Format of the Mail Buffer
69 Here is an example of the contents of a mail buffer:
72 To: subotai@@example.org
73 CC: mongol.soldier@@example.net, rms@@gnu.org
74 Subject: Re: What is best in life?
75 From: conan@@example.org
76 --text follows this line--
77 To crush your enemies, see them driven before you, and to
78 hear the lamentation of their women.
82 At the top of the mail buffer is a set of @dfn{header fields}, which
83 are used for specifying information about the email's recipient(s),
84 subject, and so on. The above buffer contains header fields for
85 @samp{To}, @samp{Cc}, @samp{Subject}, and @samp{From}. Some header
86 fields are automatically pre-initialized in the mail buffer, when
89 The line that says @samp{--text follows this line--} separates the
90 header fields from the @dfn{body} (or @dfn{text}) of the message.
91 Everything above that line is treated as part of the headers;
92 everything below it is treated as the body. The delimiter line itself
93 does not appear in the message actually sent.
95 You can insert and edit header fields using ordinary editing
96 commands. @xref{Header Editing}, for commands specific to editing
97 header fields. Certain headers, such as @samp{Date} and
98 @samp{Message-Id}, are normally omitted from the mail buffer and are
99 created automatically when the message is sent.
102 @section Mail Header Fields
103 @cindex headers (of mail message)
105 A header field in the mail buffer starts with a field name at the
106 beginning of a line, terminated by a colon. Upper and lower case are
107 equivalent in field names. After the colon and optional whitespace
108 comes the contents of the field.
110 You can use any name you like for a header field, but normally
111 people use only standard field names with accepted meanings.
113 @vindex user-full-name
114 @vindex user-mail-address
115 The @samp{From} header field identifies the person sending the email
116 (i.e., you). This should be a valid mailing address, as replies are
117 normally sent there. The default contents of this header field are
118 computed from the variables @code{user-full-name} (which specifies
119 your full name) and @code{user-mail-address} (your email address). On
120 some operating systems, Emacs initializes these two variables using
121 environment variables (@pxref{General Variables}). If this
122 information is unavailable or wrong, you should customize the
123 variables yourself (@pxref{Easy Customization}).
125 @vindex mail-from-style
126 The value of the variable @code{mail-from-style} specifies how to
127 format the contents of the @samp{From} field:
131 Use just the address, as in @samp{king@@grassland.com}.
133 Use both address and full name, as in:@*
134 @samp{king@@grassland.com (Elvis Parsley)}.
136 Use both address and full name, as in:@*
137 @samp{Elvis Parsley <king@@grassland.com>}.
138 @item any other value
139 Use @code{angles} normally. But if the address must be ``quoted'' to
140 remain syntactically valid under the @code{angles} format but not
141 under the @code{parens} format, use @code{parens} instead. This is
145 Apart from @samp{From}, here is a table of commonly-used fields:
149 The mailing address(es) to which the message is addressed. To list
150 more than one address, use commas to separate them.
153 The subject of the message.
156 Additional mailing address(es) to send the message to. This is like
157 @samp{To}, except that these readers should not regard the message as
161 Additional mailing address(es) to send the message to, which should
162 not appear in the header of the message actually sent. ``BCC'' stands
163 for @dfn{blind carbon copies}.
166 The name of a file, to which a copy of the sent message should be
167 appended. Emacs writes the message in mbox format, unless the file is
168 in Babyl format (used by Rmail before Emacs 23), in which case Emacs
169 writes in Babyl format. If an Rmail buffer is visiting the file,
170 Emacs updates it accordingly. To specify more than one file, use
171 several @samp{FCC} fields, with one file name in each field.
174 An address to which replies should be sent, instead of @samp{From}.
175 This is used if, for some reason, your @samp{From} address cannot
179 This field takes precedence over @samp{Reply-to}. It is used because
180 some mailing lists set the @samp{Reply-to} field for their own
181 purposes (a somewhat controversial practice).
183 @item Mail-followup-to
184 One of more address(es) to use as default recipient(s) for follow-up
185 messages. This is typically used when you reply to a message from a
186 mailing list that you are subscribed to, and want replies to go to the
187 list without sending an extra copy to you.
190 An identifier for the message you are replying to. Most mail readers
191 use this information to group related messages together. Normally,
192 this header is filled in automatically when you reply to a message in
193 any mail program built into Emacs.
196 Identifiers for previous related messages. Like @samp{In-reply-to},
197 this is normally filled in automatically for you.
201 The @samp{To}, @samp{CC}, and @samp{BCC} fields can appear any number
202 of times, and each such header field can contain multiple addresses,
203 separated by commas. This way, you can specify any number of places
204 to send the message. These fields can also have continuation lines:
205 one or more lines starting with whitespace, following the starting
206 line of the field, are considered part of the field. Here's an
207 example of a @samp{To} field with a continuation line:
211 To: foo@@example.net, this@@example.net,
216 @c There is also mail-specify-envelope-from and mail-envelope-from, but
217 @c these are probably not topics for the Emacs manual.
219 @vindex mail-default-headers
220 You can direct Emacs to insert certain default headers into the mail
221 buffer by setting the variable @code{mail-default-headers} to a
222 string. Then @kbd{C-x m} inserts this string into the message
223 headers. For example, here is how to add a @samp{Reply-to} and
224 @samp{FCC} header to each message:
227 (setq mail-default-headers
228 "Reply-to: foo@@example.com\nFCC: ~/Mail/sent")
232 If the default header fields are not appropriate for a
233 particular message, edit them as necessary before sending the message.
236 @section Mail Aliases
238 @cindex @file{.mailrc} file
240 @vindex mail-personal-alias-file
242 You can define @dfn{mail aliases}, which are short mnemonic names
243 that stand for one or more mailing addresses. By default, mail
244 aliases are defined in the file @file{~/.mailrc}. You can specify a
245 different file name to use, by setting the variable
246 @code{mail-personal-alias-file}.
248 To define an alias in @file{.mailrc}, write a line like this:
251 alias @var{nick} @var{fulladdresses}
255 This means that @var{nick} should expand into @var{fulladdresses},
256 where @var{fulladdresses} can be either a single address, or multiple
257 addresses separated with spaces. For instance, to make @code{maingnu}
258 stand for @code{gnu@@gnu.org} plus a local address of your own, put in
262 alias maingnu gnu@@gnu.org local-gnu
266 If an address contains a space, quote the whole address with a pair of
267 double quotes, like this:
270 alias jsmith "John Q. Smith <none@@example.com>"
274 Note that you need not include double quotes around individual parts
275 of the address, such as the person's full name. Emacs puts them in if
276 they are needed. For instance, it inserts the above address as
277 @samp{"John Q. Smith" <none@@example.com>}.
279 Emacs also recognizes ``include'' commands in @file{.mailrc}. They
283 source @var{filename}
287 The @file{.mailrc} file is not unique to Emacs; many other
288 mail-reading programs use it for mail aliases, and it can contain
289 various other commands. However, Emacs ignores everything except
290 alias definitions and include commands.
292 @findex mail-abbrev-insert-alias
293 Mail aliases expand as abbrevs---that is to say, as soon as you type
294 a word-separator character after an alias (@pxref{Abbrevs}). This
295 expansion takes place only within the @samp{To}, @samp{From},
296 @samp{CC}, @samp{BCC}, and @samp{Reply-to} header fields (plus their
297 @samp{Resent-} variants); it does not take place in other header
298 fields, such as @samp{Subject}.
300 You can also insert an aliased address directly, using the command
301 @kbd{M-x mail-abbrev-insert-alias}. This reads an alias name, with
302 completion, and inserts its definition at point.
305 @section Mail Commands
307 @cindex mode, Message
309 The default major mode for the @file{*mail*} buffer is called
310 Message mode. It behaves like Text mode in many ways, but provides
311 several additional commands on the @kbd{C-c} prefix, which make
312 editing a message more convenient.
314 In this section, we will describe some of the most commonly-used
315 commands available in Message mode.
317 Message mode also has its own manual, where its features are described
318 in greater detail. @xref{Top,,Message, message, Message}.
322 * Mail Sending:: Commands to send the message.
323 * Header Editing:: Commands to move to header fields and edit them.
324 * Citing Mail:: Quoting a message you are replying to.
325 * Mail Misc:: Attachments, spell checking, etc.
329 @subsection Mail Sending
333 Send the message, and bury the mail buffer (@code{message-send-and-exit}).
335 Send the message, and leave the mail buffer selected (@code{message-send}).
338 @kindex C-c C-s @r{(Message mode)}
339 @kindex C-c C-c @r{(Message mode)}
341 @vindex message-kill-buffer-on-exit
342 The usual command to send a message is @kbd{C-c C-c}
343 (@code{mail-send-and-exit}). This sends the message and then
344 ``buries'' the mail buffer, putting it at the lowest priority for
345 reselection. If you want it to kill the mail buffer instead, change
346 the variable @code{message-kill-buffer-on-exit} to @code{t}.
348 @findex message-send-and-exit
349 The command @kbd{C-c C-s} (@code{message-send}) sends the message
350 and leaves the buffer selected. Use this command if you want to
351 modify the message (perhaps with new recipients) and send it again.
353 @vindex message-send-hook
354 Sending a message runs the hook @code{message-send-hook}. It also
355 marks the mail buffer as unmodified, except if the mail buffer is also
356 a file-visiting buffer (in that case, only saving the file does that,
357 and you don't get a warning if you try to send the same message
364 @vindex send-mail-function
365 The variable @code{send-mail-function} controls how the message is
366 delivered. Its value should be one of the following functions:
369 @item sendmail-query-once
370 Query for a delivery method (one of the other entries in this list),
371 and use that method for this message; then save the method to
372 @code{send-mail-function}, so that it is used for future deliveries.
373 This is the default, unless you have already set the variables for
374 sending mail via @code{smtpmail-send-it} (see below).
376 @item smtpmail-send-it
377 Send mail using the through an external mail host, such as your
378 Internet service provider's outgoing SMTP mail server. If you have
379 not told Emacs how to contact the SMTP server, it prompts for this
380 information, which is saved in the @code{smtpmail-smtp-server} variable
381 and the file @file{~/.authinfo}.
382 @xref{Top,,Emacs SMTP Library, smtpmail, Sending mail via SMTP}.
384 @item sendmail-send-it
385 Send mail using the system's default @command{sendmail} program, or
386 equivalent. This requires the system to be set up for delivering mail
389 @item mailclient-send-it
390 Pass the mail buffer on to the system's designated mail client. See
391 the commentary section in the file @file{mailclient.el} for details.
393 @item feedmail-send-it
394 This is similar to @code{sendmail-send-it}, but allows you to queue
395 messages for later sending. See the commentary section in the file
396 @file{feedmail.el} for details.
399 @vindex sendmail-coding-system
400 When you send a message containing non-@acronym{ASCII} characters,
401 they need to be encoded with a coding system (@pxref{Coding Systems}).
402 Usually the coding system is specified automatically by your chosen
403 language environment (@pxref{Language Environments}). You can
404 explicitly specify the coding system for outgoing mail by setting the
405 variable @code{sendmail-coding-system} (@pxref{Recognize Coding}). If
406 the coding system thus determined does not handle the characters in a
407 particular message, Emacs asks you to select the coding system to use,
408 showing a list of possible coding systems.
411 @subsection Mail Header Editing
413 Message mode provides the following special commands to move to
414 particular header fields and to complete addresses in headers.
418 Move to the @samp{To} header (@code{message-goto-to}).
420 Move to the @samp{Subject} header (@code{message-goto-subject}).
422 Move to the @samp{CC} header (@code{message-goto-cc}).
424 Move to the @samp{BCC} header (@code{message-goto-bcc}).
426 Move to the @samp{Reply-To} header (@code{message-goto-reply-to}).
428 Move to the @samp{Mail-Followup-To} header field
429 (@code{message-goto-followup-to}).
431 Add a new @samp{FCC} header field, with file-name completion
432 (@code{message-goto-fcc}).
434 Move to the start of the message body (@code{message-goto-body}).
436 Complete a mailing address (@code{message-tab}).
439 @kindex C-c C-f C-t @r{(Message mode)}
440 @findex message-goto-to
441 @kindex C-c C-f C-s @r{(Message mode)}
442 @findex message-goto-subject
443 @kindex C-c C-f C-c @r{(Message mode)}
444 @findex message-goto-cc
445 @kindex C-c C-f C-b @r{(Message mode)}
446 @findex message-goto-bcc
447 @kindex C-c C-f C-r @r{(Message mode)}
448 @findex goto-reply-to
449 @kindex C-c C-f C-f @r{(Message mode)}
450 @findex goto-followup-to
451 @kindex C-c C-f C-w @r{(Message mode)}
452 @findex message-goto-fcc
453 The commands to move point to particular header fields are all based
454 on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field''). If the
455 field in question does not exist, the command creates one (the
456 exception is @code{mail-fcc}, which creates a new field each time).
458 @kindex C-c C-b @r{(Message mode)}
460 The command @kbd{C-c C-b} (@code{message-goto-body}) moves point to
461 just after the header separator line---that is, to the beginning of
465 @kindex TAB @r{(Message mode)}
466 While editing a header field that contains addresses, such as
467 @samp{To:}, @samp{CC:} and @samp{BCC:}, you can complete an address by
468 typing @key{TAB} (@code{message-tab}). This attempts to insert the
469 full name corresponding to the address based on a couple of methods,
470 including EUDC, a library that recognizes a number of directory server
471 protocols (@pxref{Top,,EUDC,eudc, The Emacs Unified Directory
472 Client}). Failing that, it attempts to expand the address as a mail
473 alias (@pxref{Mail Aliases}). If point is on a header field that does
474 not take addresses, or if it is in the message body, then @key{TAB}
475 just inserts a tab character.
478 @subsection Citing Mail
483 Yank the selected message from the mail reader, as a citation
484 (@code{message-yank-original}).
486 Fill each paragraph cited from another message
487 (@code{message-fill-yanked-message}).
490 @kindex C-c C-y @r{(Message mode)}
491 @findex message-yank-original
492 @findex message-yank-prefix
493 You can use the command @kbd{C-c C-y} (@code{message-yank-original})
494 to @dfn{cite} a message that you are replying to. This inserts the
495 text of that message into the mail buffer. This command works only if
496 the mail buffer is invoked from a mail reader running in Emacs, such
499 By default, Emacs inserts the string @samp{>} in front of each line
500 of the cited text; this prefix string is specified by the variable
501 @code{message-yank-prefix}. If you call @code{message-yank-original}
502 with a prefix argument, the citation prefix is not inserted.
504 @kindex C-c C-q @r{(Message mode)}
505 @findex mail-fill-yanked-message
506 After using @kbd{C-c C-y}, you can type @kbd{C-c C-q}
507 (@code{message-fill-yanked-message}) to fill the paragraphs of the
508 cited message. One use of @kbd{C-c C-q} fills all such paragraphs,
509 each one individually. To fill a single paragraph of the quoted
510 message, use @kbd{M-q}. If filling does not automatically handle the
511 type of citation prefix you use, try setting the fill prefix
512 explicitly. @xref{Filling}.
514 @vindex mail-citation-hook
515 You can customize mail citation through the hook
516 @code{mail-citation-hook}. For example, you can use the Supercite
517 package, which provides more flexible citation
518 (@pxref{Introduction,,,sc, Supercite}).
521 @subsection Mail Miscellany
523 @kindex C-c C-a @r{(Message mode)}
524 @findex mml-attach-file
526 @cindex Multipurpose Internet Mail Extensions
527 You can @dfn{attach} a file to an outgoing message by typing
528 @kbd{C-c C-a} (@code{mml-attach-file}) in the mail buffer. Attaching
529 is done using the Multipurpose Internet Mail Extensions
530 (@acronym{MIME}) standard.
532 The @code{mml-attach-file} command prompts for the name of the file,
533 and for the attachment's @dfn{content type}, @dfn{description}, and
534 @dfn{disposition}. The content type is normally detected
535 automatically; just type @key{RET} to accept the default. The
536 description is a single line of text that the recipient will see next
537 to the attachment; you may also choose to leave this empty. The
538 disposition is either @samp{inline} (the default), which means the
539 recipient will see a link to the attachment within the message body,
540 or @samp{attachment}, which means the link will be separate from the
543 @findex mail-add-attachment
544 The @code{mml-attach-file} command is specific to Message mode; in
545 Mail mode use @kbd{mail-add-attachment} instead. It will prompt only
546 for the name of the file, and will determine the content type and the
547 disposition automatically. If you want to include some description of
548 the attached file, type that in the message body.
550 The actual contents of the attached file are not inserted into the
551 mail buffer. Instead, some placeholder text is inserted into the mail
555 <#part type="text/plain" filename="~/foo.txt" disposition=inline>
560 When you type @kbd{C-c C-c} or @kbd{C-c C-s} to send the message, the
561 attached file will be delivered with it.
563 @findex ispell-message
564 While composing a message, you can do spelling correction on the
565 message text by typing @kbd{M-x ispell-message}. If you have yanked
566 an incoming message into the outgoing draft, this command skips what
567 was yanked, but it checks the text that you yourself inserted (it
568 looks for indentation or @code{mail-yank-prefix} to distinguish the
569 cited lines from your input). @xref{Spelling}.
571 @vindex mail-mode-hook
572 @vindex mail-setup-hook
573 Turning on Message mode (which @kbd{C-x m} does automatically) runs
574 the normal hooks @code{text-mode-hook} and @code{message-mode-hook}.
575 Initializing a new outgoing message runs the normal hook
576 @code{message-setup-hook}; you can use this hook if you want to make
577 changes to the appearance of the mail buffer. @xref{Hooks}.
579 The main difference between these hooks is just when they are
580 invoked. Whenever you type @kbd{C-x m}, @code{message-mode-hook} runs
581 as soon as the mail buffer is created. Then the @code{message-setup}
582 function inserts the default contents of the buffer. After these
583 default contents are inserted, @code{message-setup-hook} runs.
585 If you use @kbd{C-x m} to continue an existing composition,
586 @code{message-mode-hook} runs immediately after switching to the mail
587 buffer. If the buffer is unmodified, or if you decide to erase it and
588 start again, @code{message-setup-hook} runs after the default contents
592 @section Mail Signature
594 @cindex mail signature
595 @vindex mail-signature-file
596 @vindex mail-signature
597 You can add a standard piece of text---your @dfn{mail
598 signature}---to the end of every message. This signature may contain
599 information such as your telephone number or your physical location.
600 The variable @code{mail-signature} determines how Emacs handles the
603 The default value of @code{mail-signature} is @code{t}; this means
604 to look for your mail signature in the file @file{~/.signature}. If
605 this file exists, its contents are automatically inserted into the end
606 of the mail buffer. You can change the signature file via the
607 variable @code{mail-signature-file}.
609 If you change @code{mail-signature} to a string, that specifies the
610 text of the signature directly.
612 @kindex C-c C-w @r{(Message mode)}
613 @findex message-insert-signature
614 If you change @code{mail-signature} to @code{nil}, Emacs will not
615 insert your mail signature automatically. You can insert your mail
616 signature by typing @kbd{C-c C-w} (@code{message-insert-signature}) in
617 the mail buffer. Emacs will look for your signature in the signature
620 By convention, a mail signature should be marked by a line whose
621 contents are @samp{-- }. If your signature lacks this prefix, it is
622 added for you. The remainder of your signature should be no more than
625 @node Mail Amusements
626 @section Mail Amusements
630 @kbd{M-x spook} adds a line of randomly chosen keywords to an outgoing
631 mail message. The keywords are chosen from a list of words that suggest
632 you are discussing something subversive.
634 The idea behind this feature is the suspicion that the
635 NSA@footnote{The US National Security Agency.} and other intelligence
636 agencies snoop on all electronic mail messages that contain keywords
637 suggesting they might find them interesting. (The agencies say that
638 they don't, but that's what they @emph{would} say.) The idea is that if
639 lots of people add suspicious words to their messages, the agencies will
640 get so busy with spurious input that they will have to give up reading
641 it all. Whether or not this is true, it at least amuses some people.
643 @findex fortune-to-signature
644 @cindex fortune cookies
645 You can use the @code{fortune} program to put a ``fortune cookie''
646 message into outgoing mail. To do this, add
647 @code{fortune-to-signature} to @code{mail-setup-hook}:
650 (add-hook 'mail-setup-hook 'fortune-to-signature)
654 You will probably need to set the variable @code{fortune-file} before
658 @section Mail-Composition Methods
659 @cindex mail-composition methods
663 @cindex MH mail interface
664 @cindex Message mode for sending mail
665 In this chapter we have described the usual Emacs mode for editing
666 and sending mail---Message mode. This is only one of several
667 available modes. Prior to Emacs 23.2, the default mode was Mail mode,
668 which is similar to Message mode in many respects but lacks features
669 such as MIME support. Another available mode is MH-E
670 (@pxref{Top,,MH-E,mh-e, The Emacs Interface to MH}).
672 @vindex mail-user-agent
673 You can choose any of these @dfn{mail user agents} as your preferred
674 method for editing and sending mail. The commands @code{C-x m},
675 @code{C-x 4 m} and @code{C-x 5 m} use whichever agent you have
676 specified; so do various other parts of Emacs that send mail, such as
677 the bug reporter (@pxref{Bugs}). To specify a mail user agent,
678 customize the variable @code{mail-user-agent}. Currently, legitimate
679 values include @code{message-user-agent} (Message mode)
680 @code{sendmail-user-agent} (Mail mode), @code{gnus-user-agent}, and
681 @code{mh-e-user-agent}.
683 If you select a different mail-composition method, the information
684 in this chapter about the mail buffer and Message mode does not apply;
685 the other methods use a different format of text in a different
686 buffer, and their commands are different as well.
688 @vindex read-mail-command
689 Similarly, to specify your preferred method for reading mail,
690 customize the variable @code{read-mail-command}. The default is
691 @code{rmail} (@pxref{Rmail}).