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