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