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