sending.texi 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. @node Sending Mail, Reading Mail, Picture, Top
  2. @chapter Sending Mail
  3. @cindex mail
  4. @cindex message
  5. To send a message in Emacs, start by typing the command (@kbd{C-x m})
  6. to select and initialize the @samp{*mail*} buffer. You can then edit the text
  7. and headers of the message in the mail buffer, and type the command
  8. (@kbd{C-c C-c}) to send the message.
  9. @table @kbd
  10. @item C-x m
  11. Begin composing a message to send (@code{mail}).
  12. @item C-x 4 m
  13. Likewise, but display the message in another window
  14. (@code{mail-other-window}).
  15. @item C-c C-c
  16. In Mail mode, send the message and switch to another buffer
  17. (@code{mail-send-and-exit}).
  18. @end table
  19. @kindex C-x m
  20. @findex mail
  21. @kindex C-x 4 m
  22. @findex mail-other-window
  23. The command @kbd{C-x m} (@code{mail}) selects a buffer named
  24. @samp{*mail*} and initializes it with the skeleton of an outgoing message.
  25. @kbd{C-x 4 m} (@code{mail-other-window}) selects the @samp{*mail*} buffer
  26. in a different window, leaving the previous current buffer visible.@refill
  27. Because the buffer for mail composition is an ordinary Emacs buffer, you can
  28. switch to other buffers while in the middle of composing mail, and switch
  29. back later (or never). If you use the @kbd{C-x m} command again when you
  30. have been composing another message but have not sent it, a new mail
  31. buffer will be created; in this way, you can compose multiple messages
  32. at once. You can switch back to and complete an unsent message by using
  33. the normal buffer selection mechanisms.
  34. @kbd{C-u C-x m} is another way to switch back to a message in progress:
  35. it will search for an existing, unsent mail message buffer and select it.
  36. @menu
  37. * Format: Mail Format. Format of the mail being composed.
  38. * Headers: Mail Headers. Details of allowed mail header fields.
  39. * Mode: Mail Mode. Special commands for editing mail being composed.
  40. @end menu
  41. @node Mail Format, Mail Headers, Sending Mail, Sending Mail
  42. @section The Format of the Mail Buffer
  43. In addition to the @dfn{text} or contents, a message has @dfn{header
  44. fields}, which say who sent it, when, to whom, why, and so on. Some header
  45. fields, such as the date and sender, are created automatically after the
  46. message is sent. Others, such as the recipient names, must be specified by
  47. you in order to send the message properly.
  48. Mail mode provides a few commands to help you edit some header fields,
  49. and some are preinitialized in the buffer automatically at times. You can
  50. insert or edit any header fields using ordinary editing commands.
  51. The line in the buffer that says:
  52. @example
  53. --text follows this line--
  54. @end example
  55. @vindex mail-header-separator
  56. @noindent
  57. is a special delimiter that separates the headers you have specified from
  58. the text. Whatever follows this line is the text of the message; the
  59. headers precede it. The delimiter line itself does not appear in the
  60. message actually sent. The text used for the delimiter line is controlled
  61. by the variable @code{mail-header-separator}.
  62. Here is an example of what the headers and text in the @samp{*mail*} buffer
  63. might look like.
  64. @example
  65. To: rms@@mc
  66. CC: mly@@mc, rg@@oz
  67. Subject: The XEmacs User's Manual
  68. --Text follows this line--
  69. Please ignore this message.
  70. @end example
  71. @node Mail Headers, Mail Mode, Mail Format, Sending Mail
  72. @section Mail Header Fields
  73. @cindex headers (of mail message)
  74. There are several header fields you can use in the @samp{*mail*} buffer.
  75. Each header field starts with a field name at the beginning of a line,
  76. terminated by a colon. It does not matter whether you use upper or lower
  77. case in the field name. After the colon and optional whitespace comes the
  78. contents of the field.
  79. @table @samp
  80. @item To
  81. This field contains the mailing addresses of the message.
  82. @item Subject
  83. The contents of the @samp{Subject} field should be a piece of text that
  84. says what the message is about. Subject fields are useful because most
  85. mail-reading programs can provide a summary of messages, listing the
  86. subject of each message but not its text.
  87. @item CC
  88. This field contains additional mailing addresses to send the message
  89. to, but whose readers should not regard the message as addressed to
  90. them.
  91. @item BCC
  92. This field contains additional mailing addresses to send the message
  93. to, but which should not appear in the header of the message actually
  94. sent.
  95. @item FCC
  96. This field contains the name of one file (in Unix mail file format) to
  97. which a copy of the message should be appended when the message is
  98. sent.
  99. @item From
  100. Use the @samp{From} field to say who you are, when the account you are
  101. using to send the mail is not your own. The contents of the
  102. @samp{From} field should be a valid mailing address, since replies
  103. will normally go there.
  104. @item Reply-To
  105. Use the @samp{Reply-To} field to direct replies to a different
  106. address, not your own. @samp{From} and
  107. @samp{Reply-To} have the same effect on where replies go, but they convey a
  108. different meaning to the person who reads the message.
  109. @item In-Reply-To
  110. This field contains a piece of text describing a message you are
  111. replying to. Some mail systems can use the information to correlate
  112. related pieces of mail. This field is normally filled in by your mail
  113. handling package when you are replying to a message and you never need
  114. to think about it.
  115. @end table
  116. @noindent
  117. The @samp{To}, @samp{CC}, @samp{BCC} and @samp{FCC} fields can appear
  118. any number of times, to specify many places to send the message.
  119. @noindent
  120. The @samp{To}, @samp{CC}, and @samp{BCC}, fields can have continuation
  121. lines. All the lines starting with whitespace, following the line on
  122. which the field starts, are considered part of the field. For
  123. example,@refill
  124. @example
  125. To: foo@@here, this@@there,
  126. me@@gnu.cambridge.mass.usa.earth.spiral3281
  127. @end example
  128. @noindent
  129. @vindex mail-abbrev-mailrc-file
  130. If you have a @file{~/.mailrc} file, Emacs scans it for mail aliases the
  131. first time you try to send mail in an Emacs session. Emacs expands
  132. aliases found in the @samp{To}, @samp{CC}, and @samp{BCC} fields where
  133. appropriate. You can set the variable @code{mail-abbrev-mailrc-file} to
  134. the name of the file with mail aliases. If @code{nil}, @file{~/.mailrc}
  135. is used.
  136. @cindex .mailrc file
  137. Your @file{.mailrc} file ensures that word-abbrevs are defined for each
  138. of your mail aliases when point is in a @samp{To}, @samp{CC},
  139. @samp{BCC}, or @samp{From} field. The aliases are defined in your
  140. @file{.mailrc} file or in a file specified by the @b{MAILRC}
  141. environment variable if it exists. Your mail aliases expand any time
  142. you type a word-delimiter at the end of an abbreviation.
  143. In this version of Emacs, what you see is what you get: in contrast to
  144. some other versions, no abbreviations are expanded after you have sent the
  145. mail. This means you don't suffer the annoyance of having the system do
  146. things behind your back---if the system rewrites an address you typed,
  147. you know it immediately, instead of after the mail has been sent and
  148. it's too late to do anything about it. For example, you will never
  149. again be in trouble because you forgot to delete an old alias from your
  150. @file{.mailrc} and a new local user is given a userid which conflicts
  151. with one of your aliases.
  152. @vindex mail-abbrev-mode-regexp
  153. Your mail alias abbrevs are in effect only when point is in an
  154. appropriate header field. The mail aliases will not expand in the body
  155. of the message, or in other header fields. The default mode-specific
  156. abbrev table @code{mail-mode-abbrev-table} is used instead if defined.
  157. That means if you have been using mail-mode specific abbrevs, this code
  158. will not adversely affect you. You can control which header fields the
  159. abbrevs are used in by changing the variable @code{mail-abbrev-mode-regexp}.
  160. If auto-fill mode is on, abbrevs wrap at commas instead of at word
  161. boundaries, and header continuation lines will be properly indented.
  162. @findex mail-interactive-insert-alias
  163. You can also insert a mail alias with @code{mail-interactive-insert-alias}.
  164. This function, which is bound to @kbd{C-c C-a}, prompts you for an alias
  165. (with completion) and inserts its expansion at point.
  166. In this version of Emacs, it is possible to have lines like the
  167. following in your @file{.mailrc} file:
  168. @example
  169. alias someone "John Doe <doe@@quux.com>"
  170. @end example
  171. That is, if you want an address to have embedded spaces, simply surround
  172. it with double-quotes. The quotes are necessary because the format of
  173. the @file{.mailrc} file uses spaces as address delimiters.
  174. Aliases in the @file{.mailrc} file may be nested. For example, assume
  175. you define aliases like:
  176. @example
  177. alias group1 fred ethel
  178. alias group2 larry curly moe
  179. alias everybody group1 group2
  180. @end example
  181. When you now type @samp{everybody} on the @samp{To} line, it will expand to:
  182. @example
  183. fred, ethyl, larry, curly, moe
  184. @end example
  185. Aliases may contain forward references; the alias of @samp{everybody} in the
  186. example above can precede the aliases of @samp{group1} and @samp{group2}.
  187. In this version of Emacs, you can use the @code{source} @file{.mailrc} command
  188. for reading aliases from some other file as well.
  189. Aliases may contain hyphens, as in @code{"alias foo-bar foo@@bar"}, even
  190. though word-abbrevs normally cannot contain hyphens.
  191. To read in the contents of another @file{.mailrc}-type file from Emacs, use the
  192. command @code{M-x merge-mail-aliases}. The @code{rebuild-mail-aliases}
  193. command is similar, but deletes existing aliases first.
  194. @vindex mail-alias-separator-string
  195. If you want multiple addresses separated by a string other than @samp{,}
  196. (a comma), then set the variable @code{mail-alias-separator-string} to
  197. it. This has to be a comma bracketed by whitespace if you want any kind
  198. of reasonable behavior.
  199. @vindex mail-archive-file-name
  200. If the variable @code{mail-archive-file-name} is non-@code{nil}, it
  201. should be a string naming a file. Each time you start to edit a message
  202. to send, an @samp{FCC} field is entered for that file. Unless you
  203. remove the @samp{FCC} field, every message is written into that
  204. file when it is sent.
  205. @node Mail Mode,, Mail Headers, Sending Mail
  206. @section Mail Mode
  207. The major mode used in the @samp{*mail*} buffer is Mail mode. Mail
  208. mode is similar to Text mode, but several commands are provided on
  209. the @kbd{C-c} prefix. These commands all deal specifically with
  210. editing or sending the message.
  211. @table @kbd
  212. @item C-c C-s
  213. Send the message, and leave the @samp{*mail*} buffer selected
  214. (@code{mail-send}).
  215. @item C-c C-c
  216. Send the message, and select some other buffer (@code{mail-send-and-exit}).
  217. @item C-c C-f C-t
  218. Move to the @samp{To} header field, creating one if there is none
  219. (@code{mail-to}).
  220. @item C-c C-f C-s
  221. Move to the @samp{Subject} header field, creating one if there is
  222. none (@code{mail-subject}).
  223. @item C-c C-f C-c
  224. Move to the @samp{CC} header field, creating one if there is none
  225. (@code{mail-cc}).
  226. @item C-c C-w
  227. Insert the file @file{~/.signature} at the end of the message text
  228. (@code{mail-signature}).
  229. @item C-c C-y
  230. Yank the selected message (@code{mail-yank-original}).
  231. @item C-c C-q
  232. Fill all paragraphs of yanked old messages, each individually
  233. (@code{mail-fill-yanked-message}).
  234. @item @key{button3}
  235. Pops up a menu of useful mail-mode commands.
  236. @end table
  237. @kindex C-c C-s (Mail mode)
  238. @kindex C-c C-c (Mail mode)
  239. @findex mail-send
  240. @findex mail-send-and-exit
  241. There are two ways to send a message. @kbd{C-c C-c}
  242. (@code{mail-send-and-exit}) is the usual way to send the message. It
  243. sends the message and then deletes the window (if there is another
  244. window) or switches to another buffer. It puts the @samp{*mail*} buffer
  245. at the lowest priority for automatic reselection, since you are finished
  246. with using it. @kbd{C-c C-s} (@code{mail-send}) sends the
  247. message and marks the @samp{*mail*} buffer unmodified, but leaves that
  248. buffer selected so that you can modify the message (perhaps with new
  249. recipients) and send it again.
  250. @kindex C-c C-f C-t (Mail mode)
  251. @findex mail-to
  252. @kindex C-c C-f C-s (Mail mode)
  253. @findex mail-subject
  254. @kindex C-c C-f C-c (Mail mode)
  255. @findex mail-cc
  256. Mail mode provides some other special commands that are useful for
  257. editing the headers and text of the message before you send it. There are
  258. three commands defined to move point to particular header fields, all based
  259. on the prefix @kbd{C-c C-f} (@samp{C-f} is for ``field''). They are
  260. @kbd{C-c C-f C-t} (@code{mail-to}) to move to the @samp{To} field, @kbd{C-c
  261. C-f C-s} (@code{mail-subject}) for the @samp{Subject} field, and @kbd{C-c
  262. C-f C-c} (@code{mail-cc}) for the @samp{CC} field. These fields have
  263. special motion commands because they are edited most frequently.
  264. @kindex C-c C-w (Mail mode)
  265. @findex mail-signature
  266. @kbd{C-c C-w} (@code{mail-signature}) adds a standard piece of text at
  267. the end of the message to say more about who you are. The text comes
  268. from the file @file{.signature} in your home directory.
  269. @kindex C-c C-y (Mail mode)
  270. @findex mail-yank-original
  271. When you use an Rmail command to send mail from the Rmail mail reader,
  272. you can use @kbd{C-c C-y} @code{mail-yank-original} inside the
  273. @samp{*mail*} buffer to insert the
  274. text of the message you are replying to. Normally Rmail indents each line
  275. of that message four spaces and eliminates most header fields. A
  276. numeric argument specifies the number of spaces to indent. An argument
  277. of just @kbd{C-u} says not to indent at all and not to eliminate
  278. anything. @kbd{C-c C-y} always uses the current message from the
  279. @samp{RMAIL} buffer, so you can insert several old messages by selecting
  280. one in @samp{RMAIL}, switching to @samp{*mail*} and yanking it, then
  281. switching back to @samp{RMAIL} to select another.@refill
  282. @kindex C-c C-q (Mail mode)
  283. @findex mail-fill-yanked-message
  284. After using @kbd{C-c C-y}, you can use the command @kbd{C-c C-q}
  285. (@code{mail-fill-yanked-message}) to fill the paragraphs of the yanked
  286. old message or messages. One use of @kbd{C-c C-q} fills all such
  287. paragraphs, each one separately.
  288. Clicking the right mouse button in a mail buffer pops up a menu of
  289. the above commands, for easy access.
  290. @vindex mail-mode-hook
  291. Turning on Mail mode (which @kbd{C-x m} does automatically) calls the
  292. value of @code{text-mode-hook}, if it is not void or @code{nil}, and
  293. then calls the value of @code{mail-mode-hook} if that is not void or
  294. @code{nil}.