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