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