Rmail is the default mail reader for GNU Emacs. With it you can read multiple local and remote inboxes.

"Rmail is the primary Emacs mail-reader. I don't know how many people currently use it, but I will ignore any suggestion to treat it as unimportant."RichardStallman [1]

See GettingMail, WritingMail, and SendingMail for setup examples.

Basic Usage

Start it using ‘M-x rmail’. This moves all your mail from your local spool file and saves it in the Rmail primary file pointed by ‘rmail-file-name’ (defaults to ~/RMAIL)

In Emacs versions previous to 23, files are saved in a special format called Babyl. Starting with Emacs 23, Rmail uses one of the standard mbox formats, mboxo. Note: the mboxo format performs some irreversible conversions such as replacing “From” with “>From” if it occurs at the very start of a line of the body of the mail. For most people this is unimportant.

Reading mail

Pressing ‘h’ makes a summary window appear. You can navigate between messages with the ‘n’ and ‘p’ keys for next and previous respectively. The space key, ‘SPC’, scrolls down through messages. When you get to the end of a message, it goes on to the next message. The ‘DEL’ key does the same but in the opposite direction.

You can tell how many messages you want to appear in the summary buffer with ‘rmail-summary-window-size’.

Mailing lists

Use the handy command ‘M-x undigestify-rmail-message’ when viewing a mailing list digest to split it into separate messages. The original message is marked for deletion.

Writing mail

If you are outside a Rmail buffer (or summary buffer), you can either use ‘C-x m’ or use ‘M-x mail’.

If in a Rmail buffer, just press ‘m’ to create a new mail, ‘r’ to reply to a message, ‘f’ to forward a message.

Whatever you do, you will end up using MailMode to write a mail (if ‘mail-user-agent’ value is ‘sendmail-user-agent or derived)

Sorting mail

Labels (tags)

Simply add one or more labels to an email by pressing ‘a’ while viewing the message. You can add multiple labels at once by separating them with a comma.

To remove labels press ‘k’. As with adding labels, you can use a comma in between labels to remove more than one.

Press ‘l’ to show a summary window of the emails with the labels you’d like to see.

Output files

Rmail doesn’t use folders, but you can file messages in different rmail files. Press ‘o’ while viewing a message to add it to another rmail file. Note that if the other file is open, you’ll need to save it manually.

For example, I receive mail in my RMAIL file and add messages to separate files such as FAMILY, MAILING_LISTS, etc. I usually delete those messages so that my “inbox” file remains small.

The variable ‘rmail-output-file-alist’ lets you set default files for specified email addresses. Then you don’t have to type the name of the file each time you press ‘o’. If you set ‘rmail-automatic-folder-directives’, filing happens automatically after the mail is received from the inbox.

Dealing with spam

You can filter out spam by using RmailSpamFilter. There is also RmailSpamprobe.

Dealing with attachments and non-ASCII mails

You can display attachments using RmailMime.

Non-ASCII mails often use “encoded-words” as specified in RFC 2047. Here’s how to use rfc2047.el that comes with Emacs:

(autoload 'rfc2047-decode-string "rfc2047")
(autoload 'rfc2047-decode-region "rfc2047")
(setq rmail-message-filter
      (lambda ()
          (when (search-forward "\n\n" nil t)
              (point-min) (match-beginning 0)))))
      (function rfc2047-decode-string))

[MDL: The above only works for summary lines in Emacs 23 because rmail-message-filter is no longer used. Anyone have a fix for this?]

Editing message text and headers

Pressing ‘e’ in an rmail buffer puts you in editing mode. If you accidentally got there, press `C-c C-]’ to abort. Otherwise, make your changes, then press ‘C-c C-c’ to save them and return to reading mode.

Converting Babyl files to mbox format

If you tried Rmail with an Emacs version prior to 23 and you decide that Rmail is not for you, you can later read mail from the Babyl file if you are using Gnus. For all other mail readers, you’ll have to move the mails back into mbox format. Use ‘M-x unrmail’ to convert the mail file. You can also use the command-line tool b2m to do it. Starting with version 23, Emacs converts Babyl files back into mbox when it first reads them.

Rmail Libraries

Read mail from remote inboxes using ange-ftp with rmail-extras http://bmrc.berkeley.edu/~trey/emacs/src/rmail-extras.el (dead link? Local copy: Lisp:rmail-extras.el).

Thread messages with trmail.

RmailConversationSummary has a conversation view à la Gmail (no threading in the summary, list sender and beginning of message body instead).

Generate guesses for output and FCC files using rmailgen – Lisp:rmailgen.el

Save single messages to files using rmail-saver – Lisp:rmail-saver.el

Always show headers in the same order – RmailSortHeaders

Searching Mails

For quickly searching through your mails, you can use the external program “mairix”. There’s an Emacs interface for mairix called “mairix.el”, which ships with Emacs 23, but which you can also manually install for Emacs 22 (see MairixSearch).

Open Questions

How do I download e-mails with movemail from remote POP3 mailboxes with SSL? The GNU mailutils movemail version doesn’t seem to support SSL, only TLS encryption.

– TLS is just a synonim for SSL, to setting rmail-movemail-flags to “--tls” does the job.

– No way, I tried and movemail says some “I/O error”, I don’t know why. On the movemail list people raccomend using ‘stunnel’ to tunnel the connection using SSL. So really TLS != SSL. I think I’m back to fetchmail. And maybe another more modern emacs e-mail client that has built-in support for such basic things as MIME… Any suggestions?

– “--tls” only worked for me after installing GNU mailutils, although I could get email with rmail before installing GNU mailutils

How do you use Emacs to sort RMAIL email based on SpamAssassin headers?…

Please list instructions for a Postfix Maildir mailbox. These don’t work: http://support.cs.utah.edu/index.php?option=com_content&view=article&id=26&Itemid=52 I tried without the “mdmovemail” line since there’s a “movemail” in the /usr filesystem. Regards

Can it support mboxrd files?