Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / doc / emacs / sending.texi
CommitLineData
6bf7aab6 1@c This is part of the Emacs manual.
acaf905b 2@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2012
8838673e 3@c Free Software Foundation, Inc.
6bf7aab6 4@c See file emacs.texi for copying conditions.
65609f22 5@node Sending Mail
6bf7aab6
DL
6@chapter Sending Mail
7@cindex sending mail
8@cindex mail
e73c2434 9@cindex email
6bf7aab6
DL
10@cindex message
11
e73c2434
CY
12@kindex C-x m
13@findex compose-mail
b30941db
CY
14 To send an email message from Emacs, type @kbd{C-x m}. This
15switches to a buffer named @samp{*unsent mail*}, where you can edit
16the text and headers of the message. When done, type @kbd{C-c C-s} or
17@kbd{C-c C-c} to send it.
6bf7aab6
DL
18
19@table @kbd
20@item C-x m
e73c2434 21Begin composing mail (@code{compose-mail}).
6bf7aab6 22@item C-x 4 m
e73c2434 23Likewise, in another window (@code{compose-mail-other-window}).
6bf7aab6 24@item C-x 5 m
e73c2434 25Likewise, but in a new frame (@code{compose-mail-other-frame}).
6bf7aab6 26@item C-c C-s
e73c2434 27In the mail buffer, send the message (@code{message-send}).
6bf7aab6 28@item C-c C-c
e73c2434
CY
29In the mail buffer, send the message and bury the buffer
30(@code{message-send-and-exit}).
6bf7aab6
DL
31@end table
32
b30941db
CY
33 The mail buffer is an ordinary Emacs buffer, so you can switch to
34other buffers while composing the mail. If you want to send another
35mail before finishing the current one, type @kbd{C-x m} again to open
36a new mail buffer whose name has a different numeric suffix
37(@pxref{Misc Buffer}). If you invoke the command with a prefix
38argument, @w{@kbd{C-u C-x m}}, Emacs switches back to the last mail
39buffer, and asks if you want to erase the message in that buffer; if
40you answer no, this lets you pick up editing the message where you
41left off.
42
6bf7aab6
DL
43@kindex C-x 4 m
44@findex compose-mail-other-window
45@kindex C-x 5 m
46@findex compose-mail-other-frame
b30941db
CY
47 The command @kbd{C-x 4 m} (@code{compose-mail-other-window}) does
48the same as @kbd{C-x m}, except it displays the mail buffer in a
49different window. The command @kbd{C-x 5 m}
50(@code{compose-mail-other-frame}) does it in a new frame.
51
52 When you type @kbd{C-c C-c} or @kbd{C-c C-s} to send the mail, Emacs
53may ask you how it should deliver the mail---either directly via SMTP,
54or using some other method. @xref{Mail Sending}, for details.
8233e79a 55
6bf7aab6 56@menu
8838673e 57* Format: Mail Format. Format of a mail message.
e73c2434
CY
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.
6bf7aab6
DL
64@end menu
65
66@node Mail Format
67@section The Format of the Mail Buffer
68
b30941db 69 Here is an example of the contents of a mail buffer:
6bf7aab6
DL
70
71@example
b30941db
CY
72To: subotai@@example.org
73CC: mongol.soldier@@example.net, rms@@gnu.org
74Subject: Re: What is best in life?
75From: conan@@example.org
df1a3e06 76--text follows this line--
b30941db
CY
77To crush your enemies, see them driven before you, and to hear the
78lamentation of their women.
6bf7aab6
DL
79@end example
80
b30941db
CY
81@noindent
82At the top of the mail buffer is a set of @dfn{header fields}, which
83are used for specifying information about the email's recipient(s),
84subject, and so on. The above buffer contains header fields for
85@samp{To}, @samp{Cc}, @samp{Subject}, and @samp{From}. Some header
86fields are automatically pre-initialized in the mail buffer, when
87appropriate.
88
89 The line that says @samp{--text follows this line--} separates the
90header fields from the @dfn{body} (or @dfn{text}) of the message.
91Everything above that line is treated as part of the headers;
92everything below it is treated as the body. The delimiter line itself
93does not appear in the message actually sent.
94
95 You can insert and edit header fields using ordinary editing
96commands. @xref{Header Editing}, for commands specific to editing
97header fields. Certain headers, such as @samp{Date} and
98@samp{Message-Id}, are normally omitted from the mail buffer and are
99created automatically when the message is sent.
100
6bf7aab6
DL
101@node Mail Headers
102@section Mail Header Fields
103@cindex headers (of mail message)
104
105 A header field in the mail buffer starts with a field name at the
106beginning of a line, terminated by a colon. Upper and lower case are
b30941db
CY
107equivalent in field names. After the colon and optional whitespace
108comes the contents of the field.
6bf7aab6 109
e73c2434 110 You can use any name you like for a header field, but normally
b30941db 111people use only standard field names with accepted meanings.
6bf7aab6 112
b30941db 113@vindex user-full-name
e73c2434 114@vindex user-mail-address
b30941db
CY
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
117normally sent there. The default contents of this header field are
118computed from the variables @code{user-full-name} (which specifies
119your full name) and @code{user-mail-address} (your email address). On
120some operating systems, Emacs initializes these two variables using
121environment variables (@pxref{General Variables}). If this
122information is unavailable or wrong, you should customize the
123variables yourself (@pxref{Easy Customization}).
e73c2434 124
b30941db
CY
125@vindex mail-from-style
126 The value of the variable @code{mail-from-style} specifies how to
127format the contents of the @samp{From} field:
128
129@table @asis
130@item @code{nil}
131Use just the address, as in @samp{king@@grassland.com}.
132@item @code{parens}
133Use both address and full name, as in:@*
134@samp{king@@grassland.com (Elvis Parsley)}.
135@item @code{angles}
136Use both address and full name, as in:@*
137@samp{Elvis Parsley <king@@grassland.com>}.
138@item any other value
139Use @code{angles} normally. But if the address must be ``quoted'' to
140remain syntactically valid under the @code{angles} format but not
141under the @code{parens} format, use @code{parens} instead. This is
142the default.
143@end table
144
145 Apart from @samp{From}, here is a table of commonly-used fields:
146
147@table @samp
6bf7aab6 148@item To
e73c2434 149The mailing address(es) to which the message is addressed. To list
b30941db 150more than one address, use commas to separate them.
6bf7aab6
DL
151
152@item Subject
b30941db 153The subject of the message.
6bf7aab6
DL
154
155@item CC
e73c2434
CY
156Additional mailing address(es) to send the message to. This is like
157@samp{To}, except that these readers should not regard the message as
158directed at them.
6bf7aab6
DL
159
160@item BCC
e73c2434
CY
161Additional mailing address(es) to send the message to, which should
162not appear in the header of the message actually sent. ``BCC'' stands
163for @dfn{blind carbon copies}.
6bf7aab6
DL
164
165@item FCC
b30941db 166The name of a file, to which a copy of the sent message should be
e73c2434
CY
167appended. Emacs writes the message in mbox format, unless the file is
168in Babyl format (used by Rmail before Emacs 23), in which case Emacs
b30941db
CY
169writes in Babyl format. If an Rmail buffer is visiting the file,
170Emacs updates it accordingly. To specify more than one file, use
171several @samp{FCC} fields, with one file name in each field.
6bf7aab6
DL
172
173@item Reply-to
e73c2434 174An address to which replies should be sent, instead of @samp{From}.
b30941db
CY
175This is used if, for some reason, your @samp{From} address cannot
176receive replies.
df1a3e06 177
2186d13f 178@item Mail-reply-to
b30941db
CY
179This field takes precedence over @samp{Reply-to}. It is used because
180some mailing lists set the @samp{Reply-to} field for their own
181purposes (a somewhat controversial practice).
2186d13f 182
df1a3e06 183@item Mail-followup-to
b30941db
CY
184One of more address(es) to use as default recipient(s) for follow-up
185messages. This is typically used when you reply to a message from a
186mailing list that you are subscribed to, and want replies to go to the
187list without sending an extra copy to you.
6bf7aab6
DL
188
189@item In-reply-to
b30941db
CY
190An identifier for the message you are replying to. Most mail readers
191use this information to group related messages together. Normally,
192this header is filled in automatically when you reply to a message in
193any mail program built into Emacs.
6bf7aab6
DL
194
195@item References
b30941db
CY
196Identifiers for previous related messages. Like @samp{In-reply-to},
197this is normally filled in automatically for you.
6bf7aab6
DL
198@end table
199
e73c2434
CY
200@noindent
201The @samp{To}, @samp{CC}, and @samp{BCC} fields can appear any number
202of times, and each such header field can contain multiple addresses,
203separated by commas. This way, you can specify any number of places
204to send the message. These fields can also have continuation lines:
205one or more lines starting with whitespace, following the starting
206line of the field, are considered part of the field. Here's an
207example of a @samp{To} field with a continuation line:
6bf7aab6
DL
208
209@example
210@group
e73c2434
CY
211To: foo@@example.net, this@@example.net,
212 bob@@example.com
6bf7aab6
DL
213@end group
214@end example
215
df1a3e06
GM
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.
218
c7fa86d5 219@vindex mail-default-headers
e73c2434
CY
220 You can direct Emacs to insert certain default headers into the mail
221buffer by setting the variable @code{mail-default-headers} to a
222string. Then @kbd{C-x m} inserts this string into the message
223headers. For example, here is how to add a @samp{Reply-to} and
224@samp{FCC} header to each message:
225
226@smallexample
227(setq mail-default-headers
228 "Reply-to: foo@@example.com\nFCC: ~/Mail/sent")
229@end smallexample
230
231@noindent
232If the default header fields are not appropriate for a
2186d13f 233particular message, edit them as necessary before sending the message.
c7fa86d5 234
6bf7aab6
DL
235@node Mail Aliases
236@section Mail Aliases
237@cindex mail aliases
238@cindex @file{.mailrc} file
239@cindex mailrc file
e73c2434 240@vindex mail-personal-alias-file
6bf7aab6 241
e73c2434 242 You can define @dfn{mail aliases}, which are short mnemonic names
b30941db
CY
243that stand for one or more mailing addresses. By default, mail
244aliases are defined in the file @file{~/.mailrc}. You can specify a
245different file name to use, by setting the variable
e73c2434 246@code{mail-personal-alias-file}.
6bf7aab6 247
b30941db 248 To define an alias in @file{.mailrc}, write a line like this:
6bf7aab6
DL
249
250@example
e73c2434 251alias @var{nick} @var{fulladdresses}
6bf7aab6
DL
252@end example
253
254@noindent
e73c2434
CY
255This means that @var{nick} should expand into @var{fulladdresses},
256where @var{fulladdresses} can be either a single address, or multiple
257addresses separated with spaces. For instance, to make @code{maingnu}
258stand for @code{gnu@@gnu.org} plus a local address of your own, put in
6bf7aab6
DL
259this line:@refill
260
261@example
262alias maingnu gnu@@gnu.org local-gnu
263@end example
264
f5f79394 265@noindent
e73c2434
CY
266If an address contains a space, quote the whole address with a pair of
267double quotes, like this:
f5f79394
RS
268
269@example
2186d13f 270alias jsmith "John Q. Smith <none@@example.com>"
f5f79394
RS
271@end example
272
273@noindent
e73c2434
CY
274Note that you need not include double quotes around individual parts
275of the address, such as the person's full name. Emacs puts them in if
276they are needed. For instance, it inserts the above address as
2186d13f 277@samp{"John Q. Smith" <none@@example.com>}.
f5f79394 278
e73c2434
CY
279 Emacs also recognizes ``include'' commands in @file{.mailrc}. They
280look like this:
6bf7aab6
DL
281
282@example
283source @var{filename}
284@end example
285
286@noindent
e73c2434
CY
287The @file{.mailrc} file is not unique to Emacs; many other
288mail-reading programs use it for mail aliases, and it can contain
289various other commands. However, Emacs ignores everything except
290alias definitions and include commands.
df1a3e06 291
df1a3e06 292@findex mail-abbrev-insert-alias
e73c2434
CY
293 Mail aliases expand as abbrevs---that is to say, as soon as you type
294a word-separator character after an alias (@pxref{Abbrevs}). This
295expansion 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
298fields, such as @samp{Subject}.
299
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
302completion, and inserts its definition at point.
303
304@node Mail Commands
305@section Mail Commands
306@cindex Message mode
307@cindex mode, Message
308
309 The default major mode for the @samp{*mail*} buffer is called
310Message mode. It behaves like Text mode in many ways, but provides
311several additional commands on the @kbd{C-c} prefix, which make
312editing a message more convenient.
313
314 In this section, we will describe some of the most commonly-used
315commands available in Message mode.
316@ifnottex
317Message mode also has its own manual, where its features are described
318in greater detail. @xref{Top,,Message, message, Message}.
319@end ifnottex
6bf7aab6
DL
320
321@menu
322* Mail Sending:: Commands to send the message.
323* Header Editing:: Commands to move to header fields and edit them.
e73c2434
CY
324* Citing Mail:: Quoting a message you are replying to.
325* Mail Misc:: Attachments, spell checking, etc.
6bf7aab6
DL
326@end menu
327
328@node Mail Sending
329@subsection Mail Sending
330
6bf7aab6 331@table @kbd
6bf7aab6 332@item C-c C-c
b8ecfdfe 333Send the message, and bury the mail buffer (@code{message-send-and-exit}).
e73c2434
CY
334@item C-c C-s
335Send the message, and leave the mail buffer selected (@code{message-send}).
6bf7aab6
DL
336@end table
337
e73c2434
CY
338@kindex C-c C-s @r{(Message mode)}
339@kindex C-c C-c @r{(Message mode)}
340@findex message-send
b8ecfdfe
CY
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
e73c2434 344``buries'' the mail buffer, putting it at the lowest priority for
b8ecfdfe
CY
345reselection. If you want it to kill the mail buffer instead, change
346the variable @code{message-kill-buffer-on-exit} to @code{t}.
e73c2434
CY
347
348@findex message-send-and-exit
349 The command @kbd{C-c C-s} (@code{message-send}) sends the message
b8ecfdfe
CY
350and leaves the buffer selected. Use this command if you want to
351modify the message (perhaps with new recipients) and send it again.
e73c2434
CY
352
353@vindex message-send-hook
b8ecfdfe
CY
354 Sending a message runs the hook @code{message-send-hook}. It also
355marks the mail buffer as unmodified, except if the mail buffer is also
356a file-visiting buffer (in that case, only saving the file does that,
357and you don't get a warning if you try to send the same message
358twice).
6bf7aab6 359
b1d28079
SJ
360@cindex SMTP
361@cindex Feedmail
362@cindex Sendmail
df1a3e06 363@cindex Mailclient
b1d28079 364@vindex send-mail-function
b30941db 365 The variable @code{send-mail-function} controls how the message is
b8ecfdfe 366delivered. Its value should be one of the following functions:
8233e79a
CY
367
368@table @code
b30941db 369@item sendmail-query-once
b8ecfdfe
CY
370Query for a delivery method (one of the other entries in this list),
371and use that method for this message; then save the method to
372@code{send-mail-function}, so that it is used for future deliveries.
373This is the default, unless you have already set the variables for
374sending mail via @code{smtpmail-send-it} (see below).
b30941db
CY
375
376@item smtpmail-send-it
b8ecfdfe
CY
377Send mail using the through an external mail host, such as your
378Internet service provider's outgoing SMTP mail server. If you have
379not told Emacs how to contact the SMTP server, it prompts for this
380information, which is saved in the variables
381@code{smtpmail-smtp-server} and @code{smtpmail-auth-credentials}.
382@xref{Top,,Emacs SMTP Library, smtpmail, Sending mail via SMTP}.
b30941db 383
8233e79a 384@item sendmail-send-it
b30941db
CY
385Send mail using the system's default @command{sendmail} program, or
386equivalent. This requires the system to be set up for delivering mail
387directly via SMTP.
8233e79a
CY
388
389@item mailclient-send-it
b30941db
CY
390Pass the mail buffer on to the system's designated mail client. See
391the commentary section in the file @file{mailclient.el} for details.
8233e79a
CY
392
393@item feedmail-send-it
394This is similar to @code{sendmail-send-it}, but allows you to queue
395messages for later sending. See the commentary section in the file
b30941db 396@file{feedmail.el} for details.
8233e79a 397@end table
b1d28079 398
b8ecfdfe
CY
399@vindex sendmail-coding-system
400 When you send a message containing non-@acronym{ASCII} characters,
401they need to be encoded with a coding system (@pxref{Coding Systems}).
402Usually the coding system is specified automatically by your chosen
403language environment (@pxref{Language Environments}). You can
404explicitly specify the coding system for outgoing mail by setting the
405variable @code{sendmail-coding-system} (@pxref{Recognize Coding}). If
406the coding system thus determined does not handle the characters in a
407particular message, Emacs asks you to select the coding system to use,
408showing a list of possible coding systems.
409
6bf7aab6
DL
410@node Header Editing
411@subsection Mail Header Editing
412
e73c2434
CY
413 Message mode provides the following special commands to move to
414particular header fields and to complete addresses in headers.
6bf7aab6
DL
415
416@table @kbd
417@item C-c C-f C-t
e73c2434 418Move to the @samp{To} header (@code{message-goto-to}).
6bf7aab6 419@item C-c C-f C-s
e73c2434 420Move to the @samp{Subject} header (@code{message-goto-subject}).
6bf7aab6 421@item C-c C-f C-c
e73c2434 422Move to the @samp{CC} header (@code{message-goto-cc}).
6bf7aab6 423@item C-c C-f C-b
e73c2434 424Move to the @samp{BCC} header (@code{message-goto-bcc}).
df1a3e06 425@item C-c C-f C-r
e73c2434 426Move to the @samp{Reply-To} header (@code{message-goto-reply-to}).
6bf7aab6 427@item C-c C-f C-f
e73c2434
CY
428Move to the @samp{Mail-Followup-To} header field
429(@code{message-goto-followup-to}).
430@item C-c C-f C-w
df1a3e06 431Add a new @samp{FCC} header field, with file-name completion
e73c2434
CY
432(@code{message-goto-fcc}).
433@item C-c C-b
434Move to the start of the message body (@code{message-goto-body}).
435@item @key{TAB}
436Complete a mailing address (@code{message-tab}).
6bf7aab6
DL
437@end table
438
e73c2434
CY
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
454on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field''). If the
455field in question does not exist, the command creates one (the
456exception is @code{mail-fcc}, which creates a new field each time).
457
458@kindex C-c C-b @r{(Message mode)}
459@findex mail-text
460 The command @kbd{C-c C-b} (@code{message-goto-body}) moves point to
461just after the header separator line---that is, to the beginning of
462the body.
463
464@findex message-tab
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
468typing @key{TAB} (@code{message-tab}). This attempts to insert the
469full name corresponding to the address based on a couple of methods,
470including EUDC, a library that recognizes a number of directory server
471protocols (@pxref{Top,,EUDC,eudc, The Emacs Unified Directory
472Client}). Failing that, it attempts to expand the address as a mail
473alias (@pxref{Mail Aliases}). If point is on a header field that does
474not take addresses, or if it is in the message body, then @key{TAB}
475just inserts a tab character.
6bf7aab6
DL
476
477@node Citing Mail
478@subsection Citing Mail
479@cindex citing mail
480
6bf7aab6
DL
481@table @kbd
482@item C-c C-y
b30941db
CY
483Yank the selected message from the mail reader, as a citation
484(@code{message-yank-original}).
6bf7aab6
DL
485@item C-c C-q
486Fill each paragraph cited from another message
e73c2434 487(@code{message-fill-yanked-message}).
6bf7aab6
DL
488@end table
489
e73c2434
CY
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})
494to @dfn{cite} a message that you are replying to. This inserts the
b30941db
CY
495text of that message into the mail buffer. This command works only if
496the mail buffer is invoked from a mail reader running in Emacs, such
497as Rmail.
e73c2434
CY
498
499 By default, Emacs inserts the string @samp{>} in front of each line
500of the cited text; this prefix string is specified by the variable
501@code{message-yank-prefix}. If you call @code{message-yank-original}
502with a prefix argument, the citation prefix is not inserted.
503
504@kindex C-c C-q @r{(Message mode)}
6bf7aab6 505@findex mail-fill-yanked-message
e73c2434
CY
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
508cited message. One use of @kbd{C-c C-q} fills all such paragraphs,
509each one individually. To fill a single paragraph of the quoted
510message, use @kbd{M-q}. If filling does not automatically handle the
511type of citation prefix you use, try setting the fill prefix
6bf7aab6
DL
512explicitly. @xref{Filling}.
513
df1a3e06
GM
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
517package, which provides more flexible citation
518(@pxref{Introduction,,,sc, Supercite}).
519
e73c2434
CY
520@node Mail Misc
521@subsection Mail Miscellany
df1a3e06 522
e73c2434
CY
523@kindex C-c C-a @r{(Message mode)}
524@findex mail-attach-file
525@cindex MIME
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
c3760c17
EZ
529is done using the Multipurpose Internet Mail Extensions
530(@acronym{MIME}) standard.
e73c2434
CY
531
532 The @code{mml-attach-file} command prompts for the name of the file,
533and for the attachment's @dfn{content type}, @dfn{description}, and
534@dfn{disposition}. The content type is normally detected
535automatically; just type @key{RET} to accept the default. The
536description is a single line of text that the recipient will see next
537to the attachment; you may also choose to leave this empty. The
538disposition is either @samp{inline} (the default), which means the
539recipient will see a link to the attachment within the message body,
540or @samp{attachment}, which means the link will be separate from the
541body.
542
c3760c17
EZ
543@findex mail-add-attachment
544 The @code{mml-attach-file} command is specific to Message mode; in
545Mail mode use @kbd{mail-add-attachment} instead. It will prompt only
546for the name of the file, and will determine the content type and the
547disposition automatically. If you want to include some description of
548the attached file, type that in the message body.
549
e73c2434
CY
550 The actual contents of the attached file are not inserted into the
551mail buffer. Instead, some placeholder text is inserted into the mail
552buffer, like this:
6bf7aab6 553
e73c2434
CY
554@smallexample
555<#part type="text/plain" filename="~/foo.txt" disposition=inline>
556<#/part>
557@end smallexample
6bf7aab6 558
e73c2434
CY
559@noindent
560When you type @kbd{C-c C-c} or @kbd{C-c C-s} to send the message, the
561attached file will be delivered with it.
6bf7aab6
DL
562
563@findex ispell-message
e73c2434
CY
564 While composing a message, you can do spelling correction on the
565message text by typing @kbd{M-x ispell-message}. If you have yanked
566an incoming message into the outgoing draft, this command skips what
567was yanked, but it checks the text that you yourself inserted (it
568looks for indentation or @code{mail-yank-prefix} to distinguish the
569cited lines from your input). @xref{Spelling}.
6bf7aab6
DL
570
571@vindex mail-mode-hook
572@vindex mail-setup-hook
e73c2434
CY
573 Turning on Message mode (which @kbd{C-x m} does automatically) runs
574the normal hooks @code{text-mode-hook} and @code{message-mode-hook}.
6bf7aab6 575Initializing a new outgoing message runs the normal hook
e73c2434
CY
576@code{message-setup-hook}; you can use this hook if you want to make
577changes to the appearance of the mail buffer. @xref{Hooks}.
6bf7aab6
DL
578
579 The main difference between these hooks is just when they are
e73c2434
CY
580invoked. Whenever you type @kbd{C-x m}, @code{message-mode-hook} runs
581as soon as the mail buffer is created. Then the @code{message-setup}
582function inserts the default contents of the buffer. After these
583default contents are inserted, @code{message-setup-hook} runs.
584
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
587buffer. If the buffer is unmodified, or if you decide to erase it and
588start again, @code{message-setup-hook} runs after the default contents
589are inserted.
590
591@node Mail Signature
592@section Mail Signature
593
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
598signature}---to the end of every message. This signature may contain
599information such as your telephone number or your physical location.
600The variable @code{mail-signature} determines how Emacs handles the
601mail signature.
602
603 The default value of @code{mail-signature} is @code{t}; this means
604to look for your mail signature in the file @file{~/.signature}. If
605this file exists, its contents are automatically inserted into the end
606of the mail buffer. You can change the signature file via the
607variable @code{mail-signature-file}.
608
609 If you change @code{mail-signature} to a string, that specifies the
610text of the signature directly.
611
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
615insert your mail signature automatically. You can insert your mail
616signature by typing @kbd{C-c C-w} (@code{message-insert-signature}) in
617the mail buffer. Emacs will look for your signature in the signature
618file.
619
620 By convention, a mail signature should be marked by a line whose
621contents are @samp{-- }. If your signature lacks this prefix, it is
622added for you. The remainder of your signature should be no more than
623four lines.
df1a3e06 624
2e2cdb68
RS
625@node Mail Amusements
626@section Mail Amusements
6bf7aab6
DL
627
628@findex spook
629@cindex NSA
630 @kbd{M-x spook} adds a line of randomly chosen keywords to an outgoing
631mail message. The keywords are chosen from a list of words that suggest
632you are discussing something subversive.
633
2394fd21 634 The idea behind this feature is the suspicion that the
df1a3e06
GM
635NSA@footnote{The US National Security Agency.} and other intelligence
636agencies snoop on all electronic mail messages that contain keywords
637suggesting they might find them interesting. (The agencies say that
638they don't, but that's what they @emph{would} say.) The idea is that if
639lots of people add suspicious words to their messages, the agencies will
640get so busy with spurious input that they will have to give up reading
641it all. Whether or not this is true, it at least amuses some people.
6bf7aab6 642
58eca4a5 643@findex fortune-to-signature
58eca4a5 644@cindex fortune cookies
2e2cdb68 645 You can use the @code{fortune} program to put a ``fortune cookie''
7fc1fe09 646message into outgoing mail. To do this, add
2e2cdb68
RS
647@code{fortune-to-signature} to @code{mail-setup-hook}:
648
649@example
650(add-hook 'mail-setup-hook 'fortune-to-signature)
651@end example
58eca4a5 652
df1a3e06
GM
653@noindent
654You will probably need to set the variable @code{fortune-file} before
655using this.
656
6bf7aab6
DL
657@node Mail Methods
658@section Mail-Composition Methods
659@cindex mail-composition methods
e73c2434
CY
660@cindex Mail mode
661@cindex mode, Mail
6bf7aab6 662
26064e9b
DL
663@cindex MH mail interface
664@cindex Message mode for sending mail
2e2cdb68 665 In this chapter we have described the usual Emacs mode for editing
e73c2434
CY
666and sending mail---Message mode. This is only one of several
667available modes. Prior to Emacs 23.2, the default mode was Mail mode,
668which is similar to Message mode in many respects but lacks features
669such as MIME support. Another available mode is MH-E
670(@pxref{Top,,MH-E,mh-e, The Emacs Interface to MH}).
6bf7aab6
DL
671
672@vindex mail-user-agent
e73c2434
CY
673 You can choose any of these @dfn{mail user agents} as your preferred
674method 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
676specified; so do various other parts of Emacs that send mail, such as
677the bug reporter (@pxref{Bugs}). To specify a mail user agent,
678customize the variable @code{mail-user-agent}. Currently, legitimate
679values 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}.
6bf7aab6 682
2e2cdb68 683 If you select a different mail-composition method, the information
e73c2434
CY
684in this chapter about the mail buffer and Message mode does not apply;
685the other methods use a different format of text in a different
2e2cdb68 686buffer, and their commands are different as well.
ab5796a9 687
df1a3e06
GM
688@vindex read-mail-command
689 Similarly, to specify your preferred method for reading mail,
690customize the variable @code{read-mail-command}. The default is
691@code{rmail} (@pxref{Rmail}).