Rmail is the default mail reader for GNU Emacs. With it you can read multiple local and remote inboxes.
You should download the
‘mailutils’ package on your computer if you want the best rmail experience.
Here is a detailed Rmail configuration. A simpler example is in GettingMail.
(setq ;; The mail URL, specifying a remote mail account ;; (Omit this to read from /var/mail/user) rmail-primary-inbox-list '("pop://me%40example.com:Passw0rD@mail.example.com")) send-mail-function 'smtpmail-send-it ; Send mail via SMTP rmail-preserve-inbox 1 ; Don't delete mail from server rmail-delete-after-output 1 ; Delete original mail after copying rmail-mime-prefer-html nil ; Prefer plaintext when possible rmail-file-name "~/mail/inbox" ; The path to our inbox file rmail-secondary-file-directory "~/mail" ; The path to our other mbox files message-default-headers "Fcc: ~/mail/sent" ; Copy sent mail to the "sent" file user-full-name "Susan" ; Our full name user-mail-address "email@example.com" ; Our return address message-signature "Plop! -S") ; A signature
You can also decide how rmail handles HTML emails with the
(setq shr-use-fonts nil ; Don't load fancy fonts shr-indentation 2 ; A left-margin of 2 columns shr-use-colors nil ; Don't load special colors shr-width 70 ; Fix width to 70 columns shr-bullet "• ") ; A bullet character for <li> elements
Note that the
‘shr’ variables also apply to eww
Start rmail with
‘M-x rmail’. With no configuration, this attempts to move all your mail from your local spool file to the Rmail primary file pointed by
‘rmail-file-name’ (defaults to
Some helpful keys:
?- Full list of keybindings
n- Next message
p- Previous message
d- Mark current message for deletion
u- Unmark current message
x- Delete all marked messages
m- Compose a new email
o- Output mail to an mbox file
i- Open an mbox file
a- Add label to current message
l- Filter inbox by label
M-s- Search all mail (also see MairixSearch)
‘h’key makes a list of messages (summary) appear.
‘Backspace’to scroll through the current message.
You can tell how many messages you want to appear in the summary buffer with
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.
To start writing a new message, you can use
‘C-x m’ or
‘M-x mail’ from anywhere in Emacs.
If you are in an rmail buffer, just press
‘m’ to create a new mail,
‘r’ to reply to a message, or
‘f’ to forward a message.
By default, rmail uses MailMode for composition. You can change this by setting the
;; Use Mail mode to compose messages (default) (setq mail-user-agent 'sendmail-user-agent) ;; To use Message mode instead: (setq mail-user-agent 'message-user-agent)
When writing a message in mail mode, you can send it with
If you want to use
msmtp (or another MTA) to handle sending, you can set the following variables like so:
(setq message-send-mail-function 'message-send-mail-with-sendmail sendmail-program "/usr/bin/msmtp")
The two major sorting methods in rmail are labels and files.
You can add one or more labels to a message. You can also filter your inbox to only display certain labels.
‘a’- Add a label, or multiple separated by a comma
‘k’- Remove label
‘l’- Sort by label
You can move your mail from the inbox into different mbox files (like “family”, “work”, etc). These mbox files behave exactly the same as the inbox.
‘o’- Output message to an mbox file
‘i’- Visit an mbox file
‘rmail-output-file-alist’ lets you set default files for specified email addresses, so 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.
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 () (save-excursion (when (search-forward "\n\n" nil t) (rfc2047-decode-region (point-min) (match-beginning 0))))) rmail-summary-line-decoder (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?]
‘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.
Rmail supports mboxo files. It does not have support for maildir, mh, mboxd, or other formats. Rmail can convert Babyl files to mboxo, though.
Rmail used to store mail in a Babyl file. As of Emacs 23, rmail uses a standard mbox format: mboxo. mboxo performs some irreversible conversions such as replacing
From in the body of a mail with
>From if it occurs at the start of a line. For most people this is unimportant.
Prior to Emacs 23, rmail used the babyl file format. Rmail will automatically convert babyl to mbox, but you can also use
‘M-x unrmail’ or the command-line
You can enable TLS encryption by setting
(setq rmail-movemail-flags "--tls")
Another possible method is by using Stunnel.