Add 2010 to copyright years.
[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,
114f9c96 3@c 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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
2186d13f 94header fields, such as @samp{Date} and @samp{Message-Id}, are created
6bf7aab6
DL
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
2186d13f
GM
100edit some header fields, and some are automatically preinitialized in
101the buffer, 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
2186d13f 214@code{mail-default-reply-to} is @code{nil}, Emacs initializes it from the
df1a3e06
GM
215environment variable @env{REPLYTO}.
216
2186d13f
GM
217@item Mail-reply-to
218 This field takes precedence over @samp{Reply-to}. It is used because
219some mailing lists set the @samp{Reply-to} field for their own purposes
220(a somewhat controversial practice).
221
df1a3e06
GM
222@item Mail-followup-to
223 This field contains one or more addresses. It is typically used when
224you reply to a message from a mailing list that you are subscribed to.
225It usually indicates that you want replies to go to the list, and that
226you do not need an extra copy sent directly to you.
227
228@vindex mail-mailing-lists
229 The variable @code{mail-mailing-lists} holds a list of mailing list
230addresses that you are subscribed to. If it is non-@code{nil}, Emacs
231inserts an appropriate @samp{Mail-followup-to} header when sending mail
232to a mailing list.
233
234@c There is also "Sent-via", added by C-c C-v, but it does not seem
235@c particularly useful (?).
6bf7aab6
DL
236
237@item In-reply-to
58fa012d 238This field contains a piece of text describing the message you are
6bf7aab6
DL
239replying to. Some mail systems can use this information to correlate
240related pieces of mail. Normally this field is filled in by Rmail
241when you reply to a message in Rmail, and you never need to
242think about it (@pxref{Rmail}).
243
244@item References
2186d13f
GM
245This field lists the Message-Ids of related previous messages (a
246Message-Id is a unique identifier generated when a message is sent).
247Rmail sets up this field automatically when you reply to a message.
6bf7aab6
DL
248@end table
249
7fc1fe09
RS
250 The @samp{To}, @samp{CC}, and @samp{BCC} header fields can appear
251any number of times, and each such header field can contain multiple
252addresses, separated by commas. This way, you can specify any number
253of places to send the message. These fields can also have
254continuation lines: one or more lines starting with whitespace,
255following the starting line of the field, are considered part of the
256field. Here's an example of a @samp{To} field with a continuation
2b02353b 257line:
6bf7aab6
DL
258
259@example
260@group
261To: foo@@here.net, this@@there.net,
262 me@@gnu.cambridge.mass.usa.earth.spiral3281
263@end group
264@end example
265
266@vindex mail-from-style
267 When you send the message, if you didn't write a @samp{From} field
df1a3e06
GM
268yourself, Emacs puts in one for you, using @code{user-mail-address}.
269The variable @code{mail-from-style} controls the format:
6bf7aab6
DL
270
271@table @code
272@item nil
273Use just the email address, as in @samp{king@@grassland.com}.
274@item parens
df7593dd
KB
275Use both email address and full name, as in:@*
276@samp{king@@grassland.com (Elvis Parsley)}.
6bf7aab6 277@item angles
df7593dd
KB
278Use both email address and full name, as in:@*
279@samp{Elvis Parsley <king@@grassland.com>}.
6bf7aab6
DL
280@item system-default
281Allow the system to insert the @samp{From} field.
282@end table
283
df1a3e06
GM
284@c There is also mail-specify-envelope-from and mail-envelope-from, but
285@c these are probably not topics for the Emacs manual.
286
c7fa86d5 287@vindex mail-default-headers
2e2cdb68
RS
288 You can direct Emacs to insert certain default headers into the
289outgoing message by setting the variable @code{mail-default-headers}
290to a string. Then @code{C-x m} inserts this string into the message
291headers. If the default header fields are not appropriate for a
2186d13f 292particular message, edit them as necessary before sending the message.
c7fa86d5 293
6bf7aab6
DL
294@node Mail Aliases
295@section Mail Aliases
296@cindex mail aliases
297@cindex @file{.mailrc} file
298@cindex mailrc file
299
300 You can define @dfn{mail aliases} in a file named @file{~/.mailrc}.
301These are short mnemonic names which stand for mail addresses or groups of
302mail addresses. Like many other mail programs, Emacs expands aliases
303when they occur in the @samp{To}, @samp{From}, @samp{CC}, @samp{BCC}, and
304@samp{Reply-to} fields, plus their @samp{Resent-} variants.
df1a3e06 305@c The list is defined by mail-address-field-regexp.
6bf7aab6
DL
306
307 To define an alias in @file{~/.mailrc}, write a line in the following
308format:
309
310@example
311alias @var{shortaddress} @var{fulladdresses}
312@end example
313
314@noindent
315Here @var{fulladdresses} stands for one or more mail addresses for
316@var{shortaddress} to expand into. Separate multiple addresses with
317spaces; if an address contains a space, quote the whole address with a
df1a3e06 318pair of double quotes.
6bf7aab6
DL
319
320For instance, to make @code{maingnu} stand for
321@code{gnu@@gnu.org} plus a local address of your own, put in
322this line:@refill
323
324@example
325alias maingnu gnu@@gnu.org local-gnu
326@end example
327
f5f79394 328@noindent
df1a3e06 329Addresses specified in this way should use double quotes around an
f5f79394 330entire address when the address contains spaces. But you need not
df1a3e06 331include double quotes around parts of the address, such as the person's
f5f79394
RS
332full name. Emacs puts them in if they are needed. For example,
333
334@example
2186d13f 335alias jsmith "John Q. Smith <none@@example.com>"
f5f79394
RS
336@end example
337
338@noindent
444246ca 339is correct in @samp{.mailrc}. Emacs will insert the address as
2186d13f 340@samp{"John Q. Smith" <none@@example.com>}.
f5f79394
RS
341
342 Emacs also recognizes ``include'' commands in @samp{.mailrc} files.
6bf7aab6
DL
343They look like this:
344
345@example
346source @var{filename}
347@end example
348
349@noindent
350The file @file{~/.mailrc} is used primarily by other mail-reading
351programs; it can contain various other commands. Emacs ignores
352everything in it except for alias definitions and include commands.
353
354@findex define-mail-alias
355 Another way to define a mail alias, within Emacs alone, is with the
356@code{define-mail-alias} command. It prompts for the alias and then the
357full address. You can use it to define aliases in your @file{.emacs}
358file, like this:
359
360@example
361(define-mail-alias "maingnu" "gnu@@gnu.org")
362@end example
363
364@vindex mail-aliases
365 @code{define-mail-alias} records aliases by adding them to a
366variable named @code{mail-aliases}. If you are comfortable with
367manipulating Lisp lists, you can set @code{mail-aliases} directly. The
368initial value of @code{mail-aliases} is @code{t}, which means that
369Emacs should read @file{.mailrc} to get the proper value.
370
371@vindex mail-personal-alias-file
372 You can specify a different file name to use instead of
373@file{~/.mailrc} by setting the variable
374@code{mail-personal-alias-file}.
375
df1a3e06
GM
376@c There is also mail-alias-file for the system aliases.
377
6bf7aab6
DL
378@findex expand-mail-aliases
379 Normally, Emacs expands aliases when you send the message. You do not
380need to expand mail aliases before sending the message, but you can
381expand them if you want to see where the mail will actually go. To do
382this, use the command @kbd{M-x expand-mail-aliases}; it expands all mail
383aliases currently present in the mail headers that hold addresses.
384
385 If you like, you can have mail aliases expand as abbrevs, as soon as
386you type them in (@pxref{Abbrevs}). To enable this feature, execute the
387following:
388
389@example
49172314 390(add-hook 'mail-mode-hook 'mail-abbrevs-setup)
6bf7aab6
DL
391@end example
392
393@noindent
394@findex define-mail-abbrev
395@vindex mail-abbrevs
396This can go in your @file{.emacs} file. @xref{Hooks}. If you use this
397feature, you must use @code{define-mail-abbrev} instead of
398@code{define-mail-alias}; the latter does not work with this package.
399Note that the mail abbreviation package uses the variable
400@code{mail-abbrevs} instead of @code{mail-aliases}, and that all alias
401names are converted to lower case.
402
403@kindex C-c C-a @r{(Mail mode)}
df1a3e06 404@findex mail-abbrev-insert-alias
6bf7aab6 405 The mail abbreviation package also provides the @kbd{C-c C-a}
df1a3e06 406(@code{mail-abbrev-insert-alias}) command, which reads an alias
6bf7aab6
DL
407name (with completion) and inserts its definition at point. This is
408useful when editing the message text itself or a header field such as
409@samp{Subject} in which Emacs does not normally expand aliases.
410
411 Note that abbrevs expand only if you insert a word-separator character
412afterward. However, you can rebind @kbd{C-n} and @kbd{M->} to cause
413expansion as well. Here's how to do that:
414
415@smallexample
49172314 416(add-hook 'mail-mode-hook
444246ca
KB
417 (lambda ()
418 (define-key
419 mail-mode-map [remap next-line] 'mail-abbrev-next-line)
420 (define-key
421 mail-mode-map [remap end-of-buffer] 'mail-abbrev-end-of-buffer)))
6bf7aab6
DL
422@end smallexample
423
424@node Mail Mode
425@section Mail Mode
426@cindex Mail mode
427@cindex mode, Mail
428
429 The major mode used in the mail buffer is Mail mode, which is much
430like Text mode except that various special commands are provided on the
431@kbd{C-c} prefix. These commands all have to do specifically with
df1a3e06 432editing or sending the message.
6bf7aab6
DL
433
434 Mail mode is normally used in buffers set up automatically by the
435@code{mail} command and related commands. However, you can also switch
58fa012d
EZ
436to Mail mode in a file-visiting buffer. This is a useful thing to do if
437you have saved the text of a draft message in a file.
6bf7aab6
DL
438
439@menu
440* Mail Sending:: Commands to send the message.
441* Header Editing:: Commands to move to header fields and edit them.
442* Citing Mail:: Copying all or part of a message you are replying to.
443* Mail Mode Misc:: Spell checking, signatures, etc.
444@end menu
445
446@node Mail Sending
447@subsection Mail Sending
448
449 Mail mode has two commands for sending the message you have been
450editing:
451
452@table @kbd
453@item C-c C-s
454Send the message, and leave the mail buffer selected (@code{mail-send}).
455@item C-c C-c
456Send the message, and select some other buffer (@code{mail-send-and-exit}).
457@end table
458
459@kindex C-c C-s @r{(Mail mode)}
460@kindex C-c C-c @r{(Mail mode)}
461@findex mail-send
462@findex mail-send-and-exit
df1a3e06 463@vindex mail-send-hook
6bf7aab6
DL
464 @kbd{C-c C-s} (@code{mail-send}) sends the message and marks the mail
465buffer unmodified, but leaves that buffer selected so that you can
466modify the message (perhaps with new recipients) and send it again.
467@kbd{C-c C-c} (@code{mail-send-and-exit}) sends and then deletes the
468window or switches to another buffer. It puts the mail buffer at the
469lowest priority for reselection by default, since you are finished with
df1a3e06
GM
470using it. This is the usual way to send the message. Sending a message
471runs the hook @code{mail-send-hook}.
472
473@c Options not mentioned: mail-interactive, mail-use-dsn.
6bf7aab6
DL
474
475 In a file-visiting buffer, sending the message does not clear the
2b02353b
RS
476modified flag, because only saving the file should do that. Also, you
477don't get a warning if you try to send the same message twice.
6bf7aab6 478
4946337d
EZ
479@c This is indexed in mule.texi, node "Recognize Coding".
480@c @vindex sendmail-coding-system
76dd3692 481 When you send a message that contains non-@acronym{ASCII} characters, they need
6bf7aab6
DL
482to be encoded with a coding system (@pxref{Coding Systems}). Usually
483the coding system is specified automatically by your chosen language
484environment (@pxref{Language Environments}). You can explicitly specify
485the coding system for outgoing mail by setting the variable
4946337d 486@code{sendmail-coding-system} (@pxref{Recognize Coding}).
6bf7aab6
DL
487
488 If the coding system thus determined does not handle the characters in
489a particular message, Emacs asks you to select the coding system to use,
490showing a list of possible coding systems.
491
df1a3e06
GM
492@c Not mentioned: mail-send-nonascii.
493
b1d28079
SJ
494@cindex SMTP
495@cindex Feedmail
496@cindex Sendmail
df1a3e06 497@cindex Mailclient
b1d28079
SJ
498@vindex send-mail-function
499 The variable @code{send-mail-function} controls how the default mail
2186d13f
GM
500user agent sends mail. It should be set to a function. In most cases,
501the default is @code{sendmail-send-it}, which delivers mail using the
1bfec0f3 502Sendmail installation on the local host. On Mac OS X and MS-Windows,
4772c848
GM
503however, the default is normally @code{mailclient-send-it}, which
504passes the mail buffer on to the system's designated mail client (see
505@file{mailclient.el}). To send mail through an SMTP server, set
506@code{send-mail-function} to @code{smtpmail-send-it} and set up the
507Emacs SMTP library (@pxref{Top,,Emacs SMTP Library, smtpmail, Sending
508mail via SMTP}). Another option is @code{feedmail-send-it} (see the
509commentary section of the @file{feedmail.el} package).
b1d28079 510
6bf7aab6
DL
511@node Header Editing
512@subsection Mail Header Editing
513
514 Mail mode provides special commands to move to particular header
515fields and to complete addresses in headers.
516
517@table @kbd
518@item C-c C-f C-t
519Move to the @samp{To} header field, creating one if there is none
520(@code{mail-to}).
521@item C-c C-f C-s
522Move to the @samp{Subject} header field, creating one if there is
523none (@code{mail-subject}).
524@item C-c C-f C-c
525Move to the @samp{CC} header field, creating one if there is none
526(@code{mail-cc}).
527@item C-c C-f C-b
528Move to the @samp{BCC} header field, creating one if there is none
529(@code{mail-bcc}).
df1a3e06
GM
530@item C-c C-f C-r
531Move to the @samp{Reply-To} header field, creating one if there is none
532(@code{mail-reply-to}).
533@item C-c C-f C-a
534Move to the @samp{Mail-Reply-To} header field, creating one if there is none
535(@code{mail-mail-reply-to}).
536@item C-c C-f C-l
537Move to the @samp{Mail-Followup-To} header field, creating one if there is none
538(@code{mail-mail-followup-to}).
6bf7aab6 539@item C-c C-f C-f
df1a3e06 540Add a new @samp{FCC} header field, with file-name completion
6bf7aab6 541(@code{mail-fcc}).
df1a3e06
GM
542@c There is also C-c C-v, mail-sent-via, which adds one or more
543@c "Sent-via" headers, but I don't know what the point of that header is.
6bf7aab6
DL
544@item M-@key{TAB}
545Complete a mailing address (@code{mail-complete}).
546@end table
547
548@kindex C-c C-f C-t @r{(Mail mode)}
549@findex mail-to
550@kindex C-c C-f C-s @r{(Mail mode)}
551@findex mail-subject
552@kindex C-c C-f C-c @r{(Mail mode)}
553@findex mail-cc
554@kindex C-c C-f C-b @r{(Mail mode)}
555@findex mail-bcc
df1a3e06
GM
556@kindex C-c C-f C-r @r{(Mail mode)}
557@findex mail-reply-to
558@kindex C-c C-f C-a @r{(Mail mode)}
559@findex mail-mail-reply-to
560@kindex C-c C-f C-l @r{(Mail mode)}
561@findex mail-mail-followup-to
6bf7aab6
DL
562@kindex C-c C-f C-f @r{(Mail mode)}
563@findex mail-fcc
df1a3e06
GM
564 There are several commands to move point to particular header fields,
565all based on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field'').
566They are listed in the table above. If the field in question does not
567exist, these commands create one (the exception is @code{mail-fcc},
568which creates a new field each time). We provide special motion
569commands for these particular fields because they are the fields users
570most often want to edit.
6bf7aab6
DL
571
572@findex mail-complete
573@kindex M-TAB @r{(Mail mode)}
df1a3e06 574@c `mail-complete-alist' specifies the headers.
d4f3de7f
RS
575 While editing a header field that contains mailing addresses, such
576as @samp{To:}, @samp{CC:} and @samp{BCC:}, you can complete a mailing
577address by typing @kbd{M-@key{TAB}} (@code{mail-complete}). It
578inserts the full name corresponding to the address, if it can
579determine the full name. The variable @code{mail-complete-style}
580controls whether to insert the full name, and what style to use, as in
581@code{mail-from-style} (@pxref{Mail Headers}). (If your window
f5f79394
RS
582manager defines @kbd{M-@key{TAB}} to switch windows, you can type
583@kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i}.)
6bf7aab6
DL
584
585 For completion purposes, the valid mailing addresses are taken to be
df1a3e06
GM
586the local users' names plus your personal mail aliases (@pxref{Mail
587Aliases}). You can specify additional sources of valid addresses;
588browse the customization group @samp{mailalias} to see the variables for
589customizing this feature (@pxref{Customization Groups}).
6bf7aab6 590
df1a3e06
GM
591 If you type @kbd{M-@key{TAB}} in the body of the message, or on a
592unrecognized header, @code{mail-complete} invokes the function specified
593by @code{mail-complete-function}. By default, this is
594@code{ispell-complete-word}, as in Text mode.
6bf7aab6
DL
595
596@node Citing Mail
597@subsection Citing Mail
598@cindex citing mail
599
600 Mail mode also has commands for yanking or @dfn{citing} all or part of
601a message that you are replying to. These commands are active only when
602you started sending a message using an Rmail command.
603
604@table @kbd
605@item C-c C-y
606Yank the selected message from Rmail (@code{mail-yank-original}).
607@item C-c C-r
608Yank the region from the Rmail buffer (@code{mail-yank-region}).
609@item C-c C-q
610Fill each paragraph cited from another message
611(@code{mail-fill-yanked-message}).
df1a3e06 612@c There is also mail-split-line, but it does not seem very useful.
6bf7aab6
DL
613@end table
614
615@kindex C-c C-y @r{(Mail mode)}
616@findex mail-yank-original
617 When mail sending is invoked from the Rmail mail reader using an Rmail
2186d13f
GM
618command, @kbd{C-c C-y} can be used inside the mail buffer to insert the
619text of the message you are replying to. Normally it indents each line
df1a3e06
GM
620of that message three spaces and eliminates most header fields (as
621specified by the variable @code{mail-yank-ignored-headers}). A numeric
2186d13f
GM
622argument specifies the number of spaces to indent (the variable
623@code{mail-indentation-spaces} specifies the default number). An
624argument of just @kbd{C-u} says not to indent at all and not to
625eliminate anything. @kbd{C-c C-y} always uses the current message from
626the Rmail buffer, so you can insert several old messages by selecting
627one in Rmail, switching to @samp{*mail*} and yanking it, then switching
628back to Rmail to select another.
6bf7aab6
DL
629
630@vindex mail-yank-prefix
631 You can specify the text for @kbd{C-c C-y} to insert at the beginning
632of each line: set @code{mail-yank-prefix} to the desired string. (A
633value of @code{nil} means to use indentation; this is the default.)
634However, @kbd{C-u C-c C-y} never adds anything at the beginning of the
635inserted lines, regardless of the value of @code{mail-yank-prefix}.
636
637@kindex C-c C-r @r{(Mail mode)}
638@findex mail-yank-region
639 To yank just a part of an incoming message, set the region in Rmail to
640the part you want; then go to the @samp{*Mail*} message and type
641@kbd{C-c C-r} (@code{mail-yank-region}). Each line that is copied is
642indented or prefixed according to @code{mail-yank-prefix}.
643
644@kindex C-c C-q @r{(Mail mode)}
645@findex mail-fill-yanked-message
646 After using @kbd{C-c C-y} or @kbd{C-c C-r}, you can type @kbd{C-c C-q}
647(@code{mail-fill-yanked-message}) to fill the paragraphs of the yanked
648old message or messages. One use of @kbd{C-c C-q} fills all such
649paragraphs, each one individually. To fill a single paragraph of the
650quoted message, use @kbd{M-q}. If filling does not automatically
651handle the type of citation prefix you use, try setting the fill prefix
652explicitly. @xref{Filling}.
653
df1a3e06
GM
654@vindex mail-citation-hook
655 You can customize mail citation through the hook
656@code{mail-citation-hook}. For example, you can use the Supercite
657package, which provides more flexible citation
658(@pxref{Introduction,,,sc, Supercite}).
659
660@c No need to mention: mail-citation-prefix-regexp.
661
6bf7aab6
DL
662@node Mail Mode Misc
663@subsection Mail Mode Miscellany
664
665@table @kbd
666@item C-c C-t
667Move to the beginning of the message body text (@code{mail-text}).
668@item C-c C-w
df1a3e06 669Insert a signature at the end of the message text (@code{mail-signature}).
6bf7aab6 670@item C-c C-i @var{file} @key{RET}
df1a3e06 671Insert the contents of @var{file} at the end of the message text
6bf7aab6
DL
672(@code{mail-attach-file}).
673@item M-x ispell-message
58fa012d 674Perform spelling correction on the message text, but not on citations from
df1a3e06 675other messages, or the message headers.
6bf7aab6
DL
676@end table
677
678@kindex C-c C-t @r{(Mail mode)}
679@findex mail-text
680 @kbd{C-c C-t} (@code{mail-text}) moves point to just after the header
681separator line---that is, to the beginning of the message body text.
682
683@kindex C-c C-w @r{(Mail mode)}
684@findex mail-signature
685@vindex mail-signature
2186d13f
GM
686 @kbd{C-c C-w} (@code{mail-signature}) adds a standard piece of text
687(your @dfn{mail signature}) at the end of the message to say more about who
688you are. For example, it may contain telephone numbers, or your
689physical location. The text comes from the variable
690@code{mail-signature}. It can be a fixed string, or a Lisp expression
691that returns a string. If it is @code{t} or @code{nil}, the function
692inserts the contents of the file @code{mail-signature-file}. By
693default, this is the file @file{~/.signature} in your home directory.
df1a3e06
GM
694
695 If the variable @code{mail-signature} has a non-@code{nil} value,
696starting a mail automatically inserts your signature. Otherwise, you
697must explicitly use the command @code{mail-signature}. If you want to
698omit your signature from a particular message, just delete it from the
699buffer before you send the message.
700
701 Convention says that the start of your signature should be marked by a
702line whose contents are @samp{-- }. If your signature comes from a
703file, this prefix is added for you, but in all other cases you must add
704it yourself. The remainder of your signature should be no more than
705four lines.
6bf7aab6
DL
706
707@findex ispell-message
708 You can do spelling correction on the message text you have written
709with the command @kbd{M-x ispell-message}. If you have yanked an
710incoming message into the outgoing draft, this command skips what was
711yanked, but it checks the text that you yourself inserted. (It looks
712for indentation or @code{mail-yank-prefix} to distinguish the cited
713lines from your input.) @xref{Spelling}.
714
715@kindex C-c C-i @r{(Mail mode)}
716@findex mail-attach-file
717 To include a file in the outgoing message, you can use @kbd{C-x i},
718the usual command to insert a file in the current buffer. But it is
719often more convenient to use a special command, @kbd{C-c C-i}
720(@code{mail-attach-file}). This command inserts the file contents at
df1a3e06 721the end of the buffer, after your signature (if any), with a delimiter
f5f79394
RS
722line that includes the file name. Note that this is not a MIME
723attachment.
6bf7aab6
DL
724
725@vindex mail-mode-hook
726@vindex mail-setup-hook
727 Turning on Mail mode (which @kbd{C-x m} does automatically) runs the
728normal hooks @code{text-mode-hook} and @code{mail-mode-hook}.
729Initializing a new outgoing message runs the normal hook
730@code{mail-setup-hook}; if you want to add special fields to your mail
731header or make other changes to the appearance of the mail buffer, use
732that hook. @xref{Hooks}.
733
734 The main difference between these hooks is just when they are
735invoked. Whenever you type @kbd{M-x mail}, @code{mail-mode-hook} runs
736as soon as the @samp{*mail*} buffer is created. Then the
58fa012d 737@code{mail-setup} function inserts the default contents of the buffer.
6bf7aab6
DL
738After these default contents are inserted, @code{mail-setup-hook} runs.
739
df1a3e06
GM
740 If you use @kbd{M-x mail} to continue an existing composition,
741@code{mail-mode-hook} runs immediately after switching to the
742@samp{*mail*} buffer. If the buffer is unmodified, or if you decide to
743erase it and start again, @code{mail-setup-hook} runs after the default
744contents are inserted.
745
2e2cdb68
RS
746@node Mail Amusements
747@section Mail Amusements
6bf7aab6
DL
748
749@findex spook
750@cindex NSA
751 @kbd{M-x spook} adds a line of randomly chosen keywords to an outgoing
752mail message. The keywords are chosen from a list of words that suggest
753you are discussing something subversive.
754
2394fd21 755 The idea behind this feature is the suspicion that the
df1a3e06
GM
756NSA@footnote{The US National Security Agency.} and other intelligence
757agencies snoop on all electronic mail messages that contain keywords
758suggesting they might find them interesting. (The agencies say that
759they don't, but that's what they @emph{would} say.) The idea is that if
760lots of people add suspicious words to their messages, the agencies will
761get so busy with spurious input that they will have to give up reading
762it all. Whether or not this is true, it at least amuses some people.
6bf7aab6 763
58eca4a5 764@findex fortune-to-signature
58eca4a5 765@cindex fortune cookies
2e2cdb68 766 You can use the @code{fortune} program to put a ``fortune cookie''
7fc1fe09 767message into outgoing mail. To do this, add
2e2cdb68
RS
768@code{fortune-to-signature} to @code{mail-setup-hook}:
769
770@example
771(add-hook 'mail-setup-hook 'fortune-to-signature)
772@end example
58eca4a5 773
df1a3e06
GM
774@noindent
775You will probably need to set the variable @code{fortune-file} before
776using this.
777
6bf7aab6
DL
778@node Mail Methods
779@section Mail-Composition Methods
780@cindex mail-composition methods
781
26064e9b
DL
782@cindex MH mail interface
783@cindex Message mode for sending mail
2e2cdb68
RS
784 In this chapter we have described the usual Emacs mode for editing
785and sending mail---Mail mode. Emacs has alternative facilities for
786editing and sending mail, including
26064e9b 787MH-E and Message mode, not documented in this manual.
8921e2f3 788@xref{Top,,MH-E,mh-e, The Emacs Interface to MH}. @xref{Top,,Message,message,
26064e9b
DL
789Message Manual}. You can choose any of them as your preferred method.
790The commands @code{C-x m}, @code{C-x 4 m} and @code{C-x 5 m} use
58fa012d 791whichever agent you have specified, as do various other Emacs commands
26064e9b 792and facilities that send mail.
6bf7aab6
DL
793
794@vindex mail-user-agent
37ad3ca0 795 To specify your mail-composition method, customize the variable
6bf7aab6 796@code{mail-user-agent}. Currently legitimate values include
2e2cdb68 797@code{sendmail-user-agent} (Mail mode), @code{mh-e-user-agent},
37ad3ca0 798@code{message-user-agent} and @code{gnus-user-agent}.
6bf7aab6 799
2e2cdb68
RS
800 If you select a different mail-composition method, the information
801in this chapter about the @samp{*mail*} buffer and Mail mode does not
802apply; the other methods use a different format of text in a different
803buffer, and their commands are different as well.
ab5796a9 804
df1a3e06
GM
805@vindex read-mail-command
806 Similarly, to specify your preferred method for reading mail,
807customize the variable @code{read-mail-command}. The default is
808@code{rmail} (@pxref{Rmail}).
809
ab5796a9
MB
810@ignore
811 arch-tag: d8a3dfc3-5d87-45c5-a7f2-69871b8e4fd6
812@end ignore