sending.texi 27 KB

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