(rmail-font-lock-keywords): Treat "Mail-Reply-To" like "Reply-To".
[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,
6ed161e1 3@c 2003, 2004, 2005, 2006, 2007, 2008, 2009 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
9@cindex message
10
11 To send a message in Emacs, you start by typing a command (@kbd{C-x m})
12to select and initialize the @samp{*mail*} buffer. Then you edit the text
13and headers of the message in this buffer, and type another command
14(@kbd{C-c C-s} or @kbd{C-c C-c}) to send the message.
15
16@table @kbd
17@item C-x m
18Begin composing a message to send (@code{compose-mail}).
19@item C-x 4 m
20Likewise, but display the message in another window
21(@code{compose-mail-other-window}).
22@item C-x 5 m
23Likewise, but make a new frame (@code{compose-mail-other-frame}).
24@item C-c C-s
25In Mail mode, send the message (@code{mail-send}).
26@item C-c C-c
27Send the message and bury the mail buffer (@code{mail-send-and-exit}).
28@end table
29
30@kindex C-x m
31@findex compose-mail
32@kindex C-x 4 m
33@findex compose-mail-other-window
34@kindex C-x 5 m
35@findex compose-mail-other-frame
36 The command @kbd{C-x m} (@code{compose-mail}) selects a buffer named
37@samp{*mail*} and initializes it with the skeleton of an outgoing
38message. @kbd{C-x 4 m} (@code{compose-mail-other-window}) selects the
39@samp{*mail*} buffer in a different window, leaving the previous current
40buffer visible. @kbd{C-x 5 m} (@code{compose-mail-other-frame}) creates
41a new frame to select the @samp{*mail*} buffer.
42
43 Because the mail-composition buffer is an ordinary Emacs buffer, you can
44switch to other buffers while in the middle of composing mail, and switch
45back later (or never). If you use the @kbd{C-x m} command again when you
46have been composing another message but have not sent it, you are asked to
47confirm before the old message is erased. If you answer @kbd{n}, the
f5f79394 48@samp{*mail*} buffer remains selected with its old contents, so you can
6bf7aab6
DL
49finish the old message and send it. @kbd{C-u C-x m} is another way to do
50this. Sending the message marks the @samp{*mail*} buffer ``unmodified,''
51which avoids the need for confirmation when @kbd{C-x m} is next used.
52
53 If you are composing a message in the @samp{*mail*} buffer and want to
54send another message before finishing the first, rename the
55@samp{*mail*} buffer using @kbd{M-x rename-uniquely} (@pxref{Misc
56Buffer}). Then you can use @kbd{C-x m} or its variants described above
57to make a new @samp{*mail*} buffer. Once you've done that, you can work
58with each mail buffer independently.
59
54a05782
RS
60@vindex mail-default-directory
61 The variable @code{mail-default-directory} controls the default
62directory for mail buffers, and also says where to put their auto-save
63files.
64
df1a3e06
GM
65@c Not mentioned: mail-bury-selects-summary. Really an Rmail feature.
66
2e2cdb68
RS
67@ignore
68@c Commented out because it is not user-oriented;
69@c it doesn't say how to do some job. -- rms.
c016c701
DL
70@cindex directory servers
71@cindex LDAP
72@cindex PH/QI
73@cindex names and addresses
74There is an interface to directory servers using various protocols such
75as LDAP or the CCSO white pages directory system (PH/QI), described in a
76separate manual. It may be useful for looking up names and addresses.
77@xref{Top,,EUDC, eudc, EUDC Manual}.
2e2cdb68 78@end ignore
c016c701 79
6bf7aab6
DL
80@menu
81* Format: Mail Format. Format of the mail being composed.
df1a3e06 82* Headers: Mail Headers. Details of some standard mail header fields.
6bf7aab6
DL
83* Aliases: Mail Aliases. Abbreviating and grouping mail addresses.
84* Mode: Mail Mode. Special commands for editing mail being composed.
2e2cdb68 85* Amuse: Mail Amusements. Distracting the NSA; adding fortune messages.
2394fd21 86* Methods: Mail Methods. Using alternative mail-composition methods.
6bf7aab6
DL
87@end menu
88
89@node Mail Format
90@section The Format of the Mail Buffer
91
92 In addition to the @dfn{text} or @dfn{body}, a message has @dfn{header
93fields} which say who sent it, when, to whom, why, and so on. Some
94header fields, such as @samp{Date} and @samp{Sender}, are created
95automatically when you send the message. Others, such as the recipient
96names, must be specified by you in order to send the message properly.
97
2b02353b 98 In the mail buffer, you can insert and edit header fields using
df1a3e06 99ordinary editing commands. Mail mode provides commands to help you
2b02353b
RS
100edit some header fields, and some are preinitialized in the buffer
101automatically when appropriate.
6bf7aab6 102
df1a3e06 103@vindex mail-header-separator
6bf7aab6
DL
104 The line in the buffer that says
105
106@example
107--text follows this line--
108@end example
109
110@noindent
111is a special delimiter that separates the headers you have specified from
112the text. Whatever follows this line is the text of the message; the
113headers precede it. The delimiter line itself does not appear in the
114message actually sent. The text used for the delimiter line is controlled
115by the variable @code{mail-header-separator}.
116
2b02353b 117 Here is an example of what the headers and text in the mail buffer
6bf7aab6
DL
118might look like.
119
120@example
121To: gnu@@gnu.org
122CC: lungfish@@spam.org, byob@@spam.org
123Subject: The Emacs Manual
df1a3e06 124--text follows this line--
6bf7aab6
DL
125Please ignore this message.
126@end example
127
128@node Mail Headers
129@section Mail Header Fields
130@cindex headers (of mail message)
131
132 A header field in the mail buffer starts with a field name at the
133beginning of a line, terminated by a colon. Upper and lower case are
134equivalent in field names (and in mailing addresses also). After the
135colon and optional whitespace comes the contents of the field.
136
137 You can use any name you like for a header field, but normally people
138use only standard field names with accepted meanings. Here is a table
df1a3e06
GM
139of fields commonly used in outgoing messages. Emacs preinitializes some
140of these when you start to compose a mail, depending on various options
141you can set. You can delete or alter any header field before you send
142the message, if you wish.
6bf7aab6
DL
143
144@table @samp
145@item To
146This field contains the mailing addresses to which the message is
147addressed. If you list more than one address, use commas, not spaces,
148to separate them.
149
150@item Subject
151The contents of the @samp{Subject} field should be a piece of text
152that says what the message is about. The reason @samp{Subject} fields
153are useful is that most mail-reading programs can provide a summary of
154messages, listing the subject of each message but not its text.
155
156@item CC
157This field contains additional mailing addresses to send the message to,
158like @samp{To} except that these readers should not regard the message
159as directed at them.
160
161@item BCC
162This field contains additional mailing addresses to send the message to,
163which should not appear in the header of the message actually sent.
164Copies sent this way are called @dfn{blind carbon copies}.
165
166@vindex mail-self-blind
c7fa86d5 167@cindex copy of every outgoing message
6bf7aab6 168To send a blind carbon copy of every outgoing message to yourself, set
c7fa86d5
EZ
169the variable @code{mail-self-blind} to @code{t}. To send a blind carbon
170copy of every message to some other @var{address}, set the variable
2e2cdb68 171@code{mail-default-headers} to @code{"Bcc: @var{address}\n"}.
6bf7aab6
DL
172
173@item FCC
174This field contains the name of one file and directs Emacs to append a
df1a3e06
GM
175copy of the message to that file when you send the message. Emacs
176writes the message in mbox format, unless the file is in Babyl format
177(used by Rmail before Emacs 23), in which case Emacs writes Babyl. If
178an Rmail buffer is visiting the file, Emacs updates it accordingly.
179To specify more than one file, use several @samp{FCC} fields, with one
180file name in each field.
6bf7aab6
DL
181
182@vindex mail-archive-file-name
183To put a fixed file name in the @samp{FCC} field each time you start
184editing an outgoing message, set the variable
185@code{mail-archive-file-name} to that file name. Unless you remove the
186@samp{FCC} field before sending, the message will be written into that
187file when it is sent.
188
189@item From
df1a3e06
GM
190Use the @samp{From} field to say who you are. You might need to change
191this if the account you are using to send the mail is not your own. The
192contents of the @samp{From} field should be a valid mailing address,
193since replies will normally go there.
194
195@vindex mail-setup-with-from
196Emacs initializes this field (unless the variable
197@code{mail-setup-with-from} is @code{nil}) using
198@code{user-mail-address} as the default. If there is no @samp{From}
199field when you send a mail, Emacs adds one.
6bf7aab6
DL
200
201@item Reply-to
202Use this field to direct replies to a different address. Most
203mail-reading programs (including Rmail) automatically send replies to
204the @samp{Reply-to} address in preference to the @samp{From} address.
205By adding a @samp{Reply-to} field to your header, you can work around
206any problems your @samp{From} address may cause for replies.
207
60a96371 208@cindex @env{REPLYTO} environment variable
6bf7aab6
DL
209@vindex mail-default-reply-to
210To put a fixed @samp{Reply-to} address into every outgoing message, set
211the variable @code{mail-default-reply-to} to that address (as a string).
df1a3e06
GM
212Then Emacs initializes the message with a @samp{Reply-to} field as
213specified. When you first compose a mail, if
214@code{mail-default-reply-to} is @code{nil}, it is initialized from the
215environment variable @env{REPLYTO}.
216
217@item Mail-followup-to
218 This field contains one or more addresses. It is typically used when
219you reply to a message from a mailing list that you are subscribed to.
220It usually indicates that you want replies to go to the list, and that
221you do not need an extra copy sent directly to you.
222
223@vindex mail-mailing-lists
224 The variable @code{mail-mailing-lists} holds a list of mailing list
225addresses that you are subscribed to. If it is non-@code{nil}, Emacs
226inserts an appropriate @samp{Mail-followup-to} header when sending mail
227to a mailing list.
228
229@c There is also "Sent-via", added by C-c C-v, but it does not seem
230@c particularly useful (?).
6bf7aab6
DL
231
232@item In-reply-to
58fa012d 233This field contains a piece of text describing the message you are
6bf7aab6
DL
234replying to. Some mail systems can use this information to correlate
235related pieces of mail. Normally this field is filled in by Rmail
236when you reply to a message in Rmail, and you never need to
237think about it (@pxref{Rmail}).
238
239@item References
df1a3e06
GM
240This field lists the message IDs of related previous messages (a message
241ID is a unique identifier generated when a message is sent). Rmail sets
242up this field automatically when you reply to a message.
6bf7aab6
DL
243@end table
244
7fc1fe09
RS
245 The @samp{To}, @samp{CC}, and @samp{BCC} header fields can appear
246any number of times, and each such header field can contain multiple
247addresses, separated by commas. This way, you can specify any number
248of places to send the message. These fields can also have
249continuation lines: one or more lines starting with whitespace,
250following the starting line of the field, are considered part of the
251field. Here's an example of a @samp{To} field with a continuation
2b02353b 252line:
6bf7aab6
DL
253
254@example
255@group
256To: foo@@here.net, this@@there.net,
257 me@@gnu.cambridge.mass.usa.earth.spiral3281
258@end group
259@end example
260
261@vindex mail-from-style
262 When you send the message, if you didn't write a @samp{From} field
df1a3e06
GM
263yourself, Emacs puts in one for you, using @code{user-mail-address}.
264The variable @code{mail-from-style} controls the format:
6bf7aab6
DL
265
266@table @code
267@item nil
268Use just the email address, as in @samp{king@@grassland.com}.
269@item parens
df7593dd
KB
270Use both email address and full name, as in:@*
271@samp{king@@grassland.com (Elvis Parsley)}.
6bf7aab6 272@item angles
df7593dd
KB
273Use both email address and full name, as in:@*
274@samp{Elvis Parsley <king@@grassland.com>}.
6bf7aab6
DL
275@item system-default
276Allow the system to insert the @samp{From} field.
277@end table
278
df1a3e06
GM
279@c There is also mail-specify-envelope-from and mail-envelope-from, but
280@c these are probably not topics for the Emacs manual.
281
c7fa86d5 282@vindex mail-default-headers
2e2cdb68
RS
283 You can direct Emacs to insert certain default headers into the
284outgoing message by setting the variable @code{mail-default-headers}
285to a string. Then @code{C-x m} inserts this string into the message
286headers. If the default header fields are not appropriate for a
287particular message, edit them as appropriate before sending the
288message.
c7fa86d5 289
6bf7aab6
DL
290@node Mail Aliases
291@section Mail Aliases
292@cindex mail aliases
293@cindex @file{.mailrc} file
294@cindex mailrc file
295
296 You can define @dfn{mail aliases} in a file named @file{~/.mailrc}.
297These are short mnemonic names which stand for mail addresses or groups of
298mail addresses. Like many other mail programs, Emacs expands aliases
299when they occur in the @samp{To}, @samp{From}, @samp{CC}, @samp{BCC}, and
300@samp{Reply-to} fields, plus their @samp{Resent-} variants.
df1a3e06 301@c The list is defined by mail-address-field-regexp.
6bf7aab6
DL
302
303 To define an alias in @file{~/.mailrc}, write a line in the following
304format:
305
306@example
307alias @var{shortaddress} @var{fulladdresses}
308@end example
309
310@noindent
311Here @var{fulladdresses} stands for one or more mail addresses for
312@var{shortaddress} to expand into. Separate multiple addresses with
313spaces; if an address contains a space, quote the whole address with a
df1a3e06 314pair of double quotes.
6bf7aab6
DL
315
316For instance, to make @code{maingnu} stand for
317@code{gnu@@gnu.org} plus a local address of your own, put in
318this line:@refill
319
320@example
321alias maingnu gnu@@gnu.org local-gnu
322@end example
323
f5f79394 324@noindent
df1a3e06 325Addresses specified in this way should use double quotes around an
f5f79394 326entire address when the address contains spaces. But you need not
df1a3e06 327include double quotes around parts of the address, such as the person's
f5f79394
RS
328full name. Emacs puts them in if they are needed. For example,
329
330@example
df1a3e06 331alias pres "President of the United States <president@@whitehouse.gov>"
f5f79394
RS
332@end example
333
334@noindent
444246ca 335is correct in @samp{.mailrc}. Emacs will insert the address as
df1a3e06 336@samp{"President of the United States" <president@@whitehouse.gov>}.
f5f79394
RS
337
338 Emacs also recognizes ``include'' commands in @samp{.mailrc} files.
6bf7aab6
DL
339They look like this:
340
341@example
342source @var{filename}
343@end example
344
345@noindent
346The file @file{~/.mailrc} is used primarily by other mail-reading
347programs; it can contain various other commands. Emacs ignores
348everything in it except for alias definitions and include commands.
349
350@findex define-mail-alias
351 Another way to define a mail alias, within Emacs alone, is with the
352@code{define-mail-alias} command. It prompts for the alias and then the
353full address. You can use it to define aliases in your @file{.emacs}
354file, like this:
355
356@example
357(define-mail-alias "maingnu" "gnu@@gnu.org")
358@end example
359
360@vindex mail-aliases
361 @code{define-mail-alias} records aliases by adding them to a
362variable named @code{mail-aliases}. If you are comfortable with
363manipulating Lisp lists, you can set @code{mail-aliases} directly. The
364initial value of @code{mail-aliases} is @code{t}, which means that
365Emacs should read @file{.mailrc} to get the proper value.
366
367@vindex mail-personal-alias-file
368 You can specify a different file name to use instead of
369@file{~/.mailrc} by setting the variable
370@code{mail-personal-alias-file}.
371
df1a3e06
GM
372@c There is also mail-alias-file for the system aliases.
373
6bf7aab6
DL
374@findex expand-mail-aliases
375 Normally, Emacs expands aliases when you send the message. You do not
376need to expand mail aliases before sending the message, but you can
377expand them if you want to see where the mail will actually go. To do
378this, use the command @kbd{M-x expand-mail-aliases}; it expands all mail
379aliases currently present in the mail headers that hold addresses.
380
381 If you like, you can have mail aliases expand as abbrevs, as soon as
382you type them in (@pxref{Abbrevs}). To enable this feature, execute the
383following:
384
385@example
49172314 386(add-hook 'mail-mode-hook 'mail-abbrevs-setup)
6bf7aab6
DL
387@end example
388
389@noindent
390@findex define-mail-abbrev
391@vindex mail-abbrevs
392This can go in your @file{.emacs} file. @xref{Hooks}. If you use this
393feature, you must use @code{define-mail-abbrev} instead of
394@code{define-mail-alias}; the latter does not work with this package.
395Note that the mail abbreviation package uses the variable
396@code{mail-abbrevs} instead of @code{mail-aliases}, and that all alias
397names are converted to lower case.
398
399@kindex C-c C-a @r{(Mail mode)}
df1a3e06 400@findex mail-abbrev-insert-alias
6bf7aab6 401 The mail abbreviation package also provides the @kbd{C-c C-a}
df1a3e06 402(@code{mail-abbrev-insert-alias}) command, which reads an alias
6bf7aab6
DL
403name (with completion) and inserts its definition at point. This is
404useful when editing the message text itself or a header field such as
405@samp{Subject} in which Emacs does not normally expand aliases.
406
407 Note that abbrevs expand only if you insert a word-separator character
408afterward. However, you can rebind @kbd{C-n} and @kbd{M->} to cause
409expansion as well. Here's how to do that:
410
411@smallexample
49172314 412(add-hook 'mail-mode-hook
444246ca
KB
413 (lambda ()
414 (define-key
415 mail-mode-map [remap next-line] 'mail-abbrev-next-line)
416 (define-key
417 mail-mode-map [remap end-of-buffer] 'mail-abbrev-end-of-buffer)))
6bf7aab6
DL
418@end smallexample
419
420@node Mail Mode
421@section Mail Mode
422@cindex Mail mode
423@cindex mode, Mail
424
425 The major mode used in the mail buffer is Mail mode, which is much
426like Text mode except that various special commands are provided on the
427@kbd{C-c} prefix. These commands all have to do specifically with
df1a3e06 428editing or sending the message.
6bf7aab6
DL
429
430 Mail mode is normally used in buffers set up automatically by the
431@code{mail} command and related commands. However, you can also switch
58fa012d
EZ
432to Mail mode in a file-visiting buffer. This is a useful thing to do if
433you have saved the text of a draft message in a file.
6bf7aab6
DL
434
435@menu
436* Mail Sending:: Commands to send the message.
437* Header Editing:: Commands to move to header fields and edit them.
438* Citing Mail:: Copying all or part of a message you are replying to.
439* Mail Mode Misc:: Spell checking, signatures, etc.
440@end menu
441
442@node Mail Sending
443@subsection Mail Sending
444
445 Mail mode has two commands for sending the message you have been
446editing:
447
448@table @kbd
449@item C-c C-s
450Send the message, and leave the mail buffer selected (@code{mail-send}).
451@item C-c C-c
452Send the message, and select some other buffer (@code{mail-send-and-exit}).
453@end table
454
455@kindex C-c C-s @r{(Mail mode)}
456@kindex C-c C-c @r{(Mail mode)}
457@findex mail-send
458@findex mail-send-and-exit
df1a3e06 459@vindex mail-send-hook
6bf7aab6
DL
460 @kbd{C-c C-s} (@code{mail-send}) sends the message and marks the mail
461buffer unmodified, but leaves that buffer selected so that you can
462modify the message (perhaps with new recipients) and send it again.
463@kbd{C-c C-c} (@code{mail-send-and-exit}) sends and then deletes the
464window or switches to another buffer. It puts the mail buffer at the
465lowest priority for reselection by default, since you are finished with
df1a3e06
GM
466using it. This is the usual way to send the message. Sending a message
467runs the hook @code{mail-send-hook}.
468
469@c Options not mentioned: mail-interactive, mail-use-dsn.
6bf7aab6
DL
470
471 In a file-visiting buffer, sending the message does not clear the
2b02353b
RS
472modified flag, because only saving the file should do that. Also, you
473don't get a warning if you try to send the same message twice.
6bf7aab6 474
4946337d
EZ
475@c This is indexed in mule.texi, node "Recognize Coding".
476@c @vindex sendmail-coding-system
76dd3692 477 When you send a message that contains non-@acronym{ASCII} characters, they need
6bf7aab6
DL
478to be encoded with a coding system (@pxref{Coding Systems}). Usually
479the coding system is specified automatically by your chosen language
480environment (@pxref{Language Environments}). You can explicitly specify
481the coding system for outgoing mail by setting the variable
4946337d 482@code{sendmail-coding-system} (@pxref{Recognize Coding}).
6bf7aab6
DL
483
484 If the coding system thus determined does not handle the characters in
485a particular message, Emacs asks you to select the coding system to use,
486showing a list of possible coding systems.
487
df1a3e06
GM
488@c Not mentioned: mail-send-nonascii.
489
b1d28079
SJ
490@cindex SMTP
491@cindex Feedmail
492@cindex Sendmail
df1a3e06 493@cindex Mailclient
b1d28079
SJ
494@vindex send-mail-function
495 The variable @code{send-mail-function} controls how the default mail
496user agent sends mail. It should be set to a function. The default
497is @code{sendmail-send-it}, which delivers mail using the Sendmail
498installation on the local host. To send mail through a SMTP server,
499set it to @code{smtpmail-send-it} and set up the Emacs SMTP library
df1a3e06
GM
500(@pxref{Top,,Emacs SMTP Library, smtpmail, Sending mail via SMTP}).
501Other options are @code{feedmail-send-it} (see the commentary section of
502the @file{feedmail.el} package), and @code{mailclient-send-it} (see
503@file{mailclient.el}).
b1d28079 504
6bf7aab6
DL
505@node Header Editing
506@subsection Mail Header Editing
507
508 Mail mode provides special commands to move to particular header
509fields and to complete addresses in headers.
510
511@table @kbd
512@item C-c C-f C-t
513Move to the @samp{To} header field, creating one if there is none
514(@code{mail-to}).
515@item C-c C-f C-s
516Move to the @samp{Subject} header field, creating one if there is
517none (@code{mail-subject}).
518@item C-c C-f C-c
519Move to the @samp{CC} header field, creating one if there is none
520(@code{mail-cc}).
521@item C-c C-f C-b
522Move to the @samp{BCC} header field, creating one if there is none
523(@code{mail-bcc}).
df1a3e06
GM
524@item C-c C-f C-r
525Move to the @samp{Reply-To} header field, creating one if there is none
526(@code{mail-reply-to}).
527@item C-c C-f C-a
528Move to the @samp{Mail-Reply-To} header field, creating one if there is none
529(@code{mail-mail-reply-to}).
530@item C-c C-f C-l
531Move to the @samp{Mail-Followup-To} header field, creating one if there is none
532(@code{mail-mail-followup-to}).
6bf7aab6 533@item C-c C-f C-f
df1a3e06 534Add a new @samp{FCC} header field, with file-name completion
6bf7aab6 535(@code{mail-fcc}).
df1a3e06
GM
536@c There is also C-c C-v, mail-sent-via, which adds one or more
537@c "Sent-via" headers, but I don't know what the point of that header is.
6bf7aab6
DL
538@item M-@key{TAB}
539Complete a mailing address (@code{mail-complete}).
540@end table
541
542@kindex C-c C-f C-t @r{(Mail mode)}
543@findex mail-to
544@kindex C-c C-f C-s @r{(Mail mode)}
545@findex mail-subject
546@kindex C-c C-f C-c @r{(Mail mode)}
547@findex mail-cc
548@kindex C-c C-f C-b @r{(Mail mode)}
549@findex mail-bcc
df1a3e06
GM
550@kindex C-c C-f C-r @r{(Mail mode)}
551@findex mail-reply-to
552@kindex C-c C-f C-a @r{(Mail mode)}
553@findex mail-mail-reply-to
554@kindex C-c C-f C-l @r{(Mail mode)}
555@findex mail-mail-followup-to
6bf7aab6
DL
556@kindex C-c C-f C-f @r{(Mail mode)}
557@findex mail-fcc
df1a3e06
GM
558 There are several commands to move point to particular header fields,
559all based on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field'').
560They are listed in the table above. If the field in question does not
561exist, these commands create one (the exception is @code{mail-fcc},
562which creates a new field each time). We provide special motion
563commands for these particular fields because they are the fields users
564most often want to edit.
6bf7aab6
DL
565
566@findex mail-complete
567@kindex M-TAB @r{(Mail mode)}
df1a3e06 568@c `mail-complete-alist' specifies the headers.
d4f3de7f
RS
569 While editing a header field that contains mailing addresses, such
570as @samp{To:}, @samp{CC:} and @samp{BCC:}, you can complete a mailing
571address by typing @kbd{M-@key{TAB}} (@code{mail-complete}). It
572inserts the full name corresponding to the address, if it can
573determine the full name. The variable @code{mail-complete-style}
574controls whether to insert the full name, and what style to use, as in
575@code{mail-from-style} (@pxref{Mail Headers}). (If your window
f5f79394
RS
576manager defines @kbd{M-@key{TAB}} to switch windows, you can type
577@kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i}.)
6bf7aab6
DL
578
579 For completion purposes, the valid mailing addresses are taken to be
df1a3e06
GM
580the local users' names plus your personal mail aliases (@pxref{Mail
581Aliases}). You can specify additional sources of valid addresses;
582browse the customization group @samp{mailalias} to see the variables for
583customizing this feature (@pxref{Customization Groups}).
6bf7aab6 584
df1a3e06
GM
585 If you type @kbd{M-@key{TAB}} in the body of the message, or on a
586unrecognized header, @code{mail-complete} invokes the function specified
587by @code{mail-complete-function}. By default, this is
588@code{ispell-complete-word}, as in Text mode.
6bf7aab6
DL
589
590@node Citing Mail
591@subsection Citing Mail
592@cindex citing mail
593
594 Mail mode also has commands for yanking or @dfn{citing} all or part of
595a message that you are replying to. These commands are active only when
596you started sending a message using an Rmail command.
597
598@table @kbd
599@item C-c C-y
600Yank the selected message from Rmail (@code{mail-yank-original}).
601@item C-c C-r
602Yank the region from the Rmail buffer (@code{mail-yank-region}).
603@item C-c C-q
604Fill each paragraph cited from another message
605(@code{mail-fill-yanked-message}).
df1a3e06 606@c There is also mail-split-line, but it does not seem very useful.
6bf7aab6
DL
607@end table
608
609@kindex C-c C-y @r{(Mail mode)}
610@findex mail-yank-original
611 When mail sending is invoked from the Rmail mail reader using an Rmail
612command, @kbd{C-c C-y} can be used inside the mail buffer to insert
613the text of the message you are replying to. Normally it indents each line
df1a3e06
GM
614of that message three spaces and eliminates most header fields (as
615specified by the variable @code{mail-yank-ignored-headers}). A numeric
6bf7aab6
DL
616argument specifies the number of spaces to indent. An argument of just
617@kbd{C-u} says not to indent at all and not to eliminate anything.
618@kbd{C-c C-y} always uses the current message from the Rmail buffer,
619so you can insert several old messages by selecting one in Rmail,
620switching to @samp{*mail*} and yanking it, then switching back to
621Rmail to select another.
622
623@vindex mail-yank-prefix
624 You can specify the text for @kbd{C-c C-y} to insert at the beginning
625of each line: set @code{mail-yank-prefix} to the desired string. (A
626value of @code{nil} means to use indentation; this is the default.)
627However, @kbd{C-u C-c C-y} never adds anything at the beginning of the
628inserted lines, regardless of the value of @code{mail-yank-prefix}.
df1a3e06 629@c Indentation controlled by mail-indentation-spaces.
6bf7aab6
DL
630
631@kindex C-c C-r @r{(Mail mode)}
632@findex mail-yank-region
633 To yank just a part of an incoming message, set the region in Rmail to
634the part you want; then go to the @samp{*Mail*} message and type
635@kbd{C-c C-r} (@code{mail-yank-region}). Each line that is copied is
636indented or prefixed according to @code{mail-yank-prefix}.
637
638@kindex C-c C-q @r{(Mail mode)}
639@findex mail-fill-yanked-message
640 After using @kbd{C-c C-y} or @kbd{C-c C-r}, you can type @kbd{C-c C-q}
641(@code{mail-fill-yanked-message}) to fill the paragraphs of the yanked
642old message or messages. One use of @kbd{C-c C-q} fills all such
643paragraphs, each one individually. To fill a single paragraph of the
644quoted message, use @kbd{M-q}. If filling does not automatically
645handle the type of citation prefix you use, try setting the fill prefix
646explicitly. @xref{Filling}.
647
df1a3e06
GM
648@vindex mail-citation-hook
649 You can customize mail citation through the hook
650@code{mail-citation-hook}. For example, you can use the Supercite
651package, which provides more flexible citation
652(@pxref{Introduction,,,sc, Supercite}).
653
654@c No need to mention: mail-citation-prefix-regexp.
655
6bf7aab6
DL
656@node Mail Mode Misc
657@subsection Mail Mode Miscellany
658
659@table @kbd
660@item C-c C-t
661Move to the beginning of the message body text (@code{mail-text}).
662@item C-c C-w
df1a3e06 663Insert a signature at the end of the message text (@code{mail-signature}).
6bf7aab6 664@item C-c C-i @var{file} @key{RET}
df1a3e06 665Insert the contents of @var{file} at the end of the message text
6bf7aab6
DL
666(@code{mail-attach-file}).
667@item M-x ispell-message
58fa012d 668Perform spelling correction on the message text, but not on citations from
df1a3e06 669other messages, or the message headers.
6bf7aab6
DL
670@end table
671
672@kindex C-c C-t @r{(Mail mode)}
673@findex mail-text
674 @kbd{C-c C-t} (@code{mail-text}) moves point to just after the header
675separator line---that is, to the beginning of the message body text.
676
677@kindex C-c C-w @r{(Mail mode)}
678@findex mail-signature
679@vindex mail-signature
680 @kbd{C-c C-w} (@code{mail-signature}) adds a standard piece of text at
df1a3e06
GM
681the end of the message to say more about who you are. For example, it
682may contain telephone numbers, or your physical location. The text
683comes from the variable @code{mail-signature}. It can be a fixed
684string, or a Lisp expression that returns a string. If it is @code{t}
685or @code{nil}, the function inserts the contents of the file
686@code{mail-signature-file}. By default, this is the file
687@file{~/.signature} in your home directory.
688
689 If the variable @code{mail-signature} has a non-@code{nil} value,
690starting a mail automatically inserts your signature. Otherwise, you
691must explicitly use the command @code{mail-signature}. If you want to
692omit your signature from a particular message, just delete it from the
693buffer before you send the message.
694
695 Convention says that the start of your signature should be marked by a
696line whose contents are @samp{-- }. If your signature comes from a
697file, this prefix is added for you, but in all other cases you must add
698it yourself. The remainder of your signature should be no more than
699four lines.
6bf7aab6
DL
700
701@findex ispell-message
702 You can do spelling correction on the message text you have written
703with the command @kbd{M-x ispell-message}. If you have yanked an
704incoming message into the outgoing draft, this command skips what was
705yanked, but it checks the text that you yourself inserted. (It looks
706for indentation or @code{mail-yank-prefix} to distinguish the cited
707lines from your input.) @xref{Spelling}.
708
709@kindex C-c C-i @r{(Mail mode)}
710@findex mail-attach-file
711 To include a file in the outgoing message, you can use @kbd{C-x i},
712the usual command to insert a file in the current buffer. But it is
713often more convenient to use a special command, @kbd{C-c C-i}
714(@code{mail-attach-file}). This command inserts the file contents at
df1a3e06 715the end of the buffer, after your signature (if any), with a delimiter
f5f79394
RS
716line that includes the file name. Note that this is not a MIME
717attachment.
6bf7aab6
DL
718
719@vindex mail-mode-hook
720@vindex mail-setup-hook
721 Turning on Mail mode (which @kbd{C-x m} does automatically) runs the
722normal hooks @code{text-mode-hook} and @code{mail-mode-hook}.
723Initializing a new outgoing message runs the normal hook
724@code{mail-setup-hook}; if you want to add special fields to your mail
725header or make other changes to the appearance of the mail buffer, use
726that hook. @xref{Hooks}.
727
728 The main difference between these hooks is just when they are
729invoked. Whenever you type @kbd{M-x mail}, @code{mail-mode-hook} runs
730as soon as the @samp{*mail*} buffer is created. Then the
58fa012d 731@code{mail-setup} function inserts the default contents of the buffer.
6bf7aab6
DL
732After these default contents are inserted, @code{mail-setup-hook} runs.
733
df1a3e06
GM
734 If you use @kbd{M-x mail} to continue an existing composition,
735@code{mail-mode-hook} runs immediately after switching to the
736@samp{*mail*} buffer. If the buffer is unmodified, or if you decide to
737erase it and start again, @code{mail-setup-hook} runs after the default
738contents are inserted.
739
2e2cdb68
RS
740@node Mail Amusements
741@section Mail Amusements
6bf7aab6
DL
742
743@findex spook
744@cindex NSA
745 @kbd{M-x spook} adds a line of randomly chosen keywords to an outgoing
746mail message. The keywords are chosen from a list of words that suggest
747you are discussing something subversive.
748
2394fd21 749 The idea behind this feature is the suspicion that the
df1a3e06
GM
750NSA@footnote{The US National Security Agency.} and other intelligence
751agencies snoop on all electronic mail messages that contain keywords
752suggesting they might find them interesting. (The agencies say that
753they don't, but that's what they @emph{would} say.) The idea is that if
754lots of people add suspicious words to their messages, the agencies will
755get so busy with spurious input that they will have to give up reading
756it all. Whether or not this is true, it at least amuses some people.
6bf7aab6 757
58eca4a5 758@findex fortune-to-signature
58eca4a5 759@cindex fortune cookies
2e2cdb68 760 You can use the @code{fortune} program to put a ``fortune cookie''
7fc1fe09 761message into outgoing mail. To do this, add
2e2cdb68
RS
762@code{fortune-to-signature} to @code{mail-setup-hook}:
763
764@example
765(add-hook 'mail-setup-hook 'fortune-to-signature)
766@end example
58eca4a5 767
df1a3e06
GM
768@noindent
769You will probably need to set the variable @code{fortune-file} before
770using this.
771
6bf7aab6
DL
772@node Mail Methods
773@section Mail-Composition Methods
774@cindex mail-composition methods
775
26064e9b
DL
776@cindex MH mail interface
777@cindex Message mode for sending mail
2e2cdb68
RS
778 In this chapter we have described the usual Emacs mode for editing
779and sending mail---Mail mode. Emacs has alternative facilities for
780editing and sending mail, including
26064e9b 781MH-E and Message mode, not documented in this manual.
8921e2f3 782@xref{Top,,MH-E,mh-e, The Emacs Interface to MH}. @xref{Top,,Message,message,
26064e9b
DL
783Message Manual}. You can choose any of them as your preferred method.
784The commands @code{C-x m}, @code{C-x 4 m} and @code{C-x 5 m} use
58fa012d 785whichever agent you have specified, as do various other Emacs commands
26064e9b 786and facilities that send mail.
6bf7aab6
DL
787
788@vindex mail-user-agent
37ad3ca0 789 To specify your mail-composition method, customize the variable
6bf7aab6 790@code{mail-user-agent}. Currently legitimate values include
2e2cdb68 791@code{sendmail-user-agent} (Mail mode), @code{mh-e-user-agent},
37ad3ca0 792@code{message-user-agent} and @code{gnus-user-agent}.
6bf7aab6 793
2e2cdb68
RS
794 If you select a different mail-composition method, the information
795in this chapter about the @samp{*mail*} buffer and Mail mode does not
796apply; the other methods use a different format of text in a different
797buffer, and their commands are different as well.
ab5796a9 798
df1a3e06
GM
799@vindex read-mail-command
800 Similarly, to specify your preferred method for reading mail,
801customize the variable @code{read-mail-command}. The default is
802@code{rmail} (@pxref{Rmail}).
803
ab5796a9
MB
804@ignore
805 arch-tag: d8a3dfc3-5d87-45c5-a7f2-69871b8e4fd6
806@end ignore