Next: , Up: Mail Mode


35.4.1 Mail Sending

Mail mode has two commands for sending the message you have been editing:

C-c C-s
Send the message, and leave the mail buffer selected (mail-send).
C-c C-c
Send the message, and select some other buffer (mail-send-and-exit).

C-c C-s (mail-send) sends the message and marks the mail buffer unmodified, but leaves that buffer selected so that you can modify the message (perhaps with new recipients) and send it again. C-c C-c (mail-send-and-exit) sends and then deletes the window or switches to another buffer. It puts the mail buffer at the lowest priority for reselection by default, since you are finished with using it. This is the usual way to send the message. Sending a message runs the hook mail-send-hook.

In a file-visiting buffer, sending the message does not clear the modified flag, because only saving the file should do that. Also, you don't get a warning if you try to send the same message twice.

When you send a message that contains non-ASCII characters, they need to be encoded with a coding system (see Coding Systems). Usually the coding system is specified automatically by your chosen language environment (see Language Environments). You can explicitly specify the coding system for outgoing mail by setting the variable sendmail-coding-system (see Recognize Coding).

If the coding system thus determined does not handle the characters in a particular message, Emacs asks you to select the coding system to use, showing a list of possible coding systems.

The variable send-mail-function controls how the default mail user agent sends mail. It should be set to a function. In most cases, the default is sendmail-send-it, which delivers mail using the Sendmail installation on the local host. On Mac OS X and MS-Windows, however, the default is normally mailclient-send-it, which passes the mail buffer on to the system's designated mail client (see mailclient.el). To send mail through an SMTP server, set send-mail-function to smtpmail-send-it and set up the Emacs SMTP library (see Emacs SMTP Library). Another option is feedmail-send-it (see the commentary section of the feedmail.el package).