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