![[Home]](https://www.emacswiki.org/images/logo218x38.png)
This page describes how to retrieve and read email from within Emacs.
Note: Some clients delete your mail from the server after downloading it. If you want to keep your mail on the server, you must tell your client to preserve it.
Here’s an example of an Rmail configuration:
(setq rmail-primary-inbox-list '("pop://me%40example.com@mail.example.com") rmail-preserve-inbox t user-full-name "Funky Turtle" user-mail-address "me@example.com")
‘mailutils’ package on your computer.‘rmail-primary-inbox-list’ uses the URL scheme: protocol:// username @ hostname%40 is an ANSI code representing the @ symbol (see the note on movemail below)‘rmail-preserve-inbox’ tells rmail to copy the mail from the server (don’t delete it).Here’s an example of Gnus using the ‘nnml’ backend with POP:
(setq gnus-secondary-select-methods '((nnml "")) mail-sources '((pop :server "pop.example.com" :user "me@example.com")))
An example of MH-E using POP:
#: In ~/.mh_profile Path: mail inc: -host mail.example.com -user me@example.com
Emacs freezes up during sending / receiving if Emacs does it itself, so if you are downloading large emails, you will be unable to do multitasking. It may be a better idea to use another program like mpop to retrieve mail.
Instead of making Emacs retrieve your mail, you can run a program like ‘mpop’ outside of Emacs to download new mail to a folder, before managing it from inside Emacs.
The mpop config file is in ~/.mpop and looks like this:
defaults
tls on
keep on
account default
host mail.example.com
port 995
user alex@example.com
password p4ssw0rd
delivery maildir "~/mail"
Running mpop from the commandline fetches your mail and moves it into the inbox you provided.
For sending mail via SMTP, msmtp was written by the same author, and is a popular alternative to sendmail.
Emacs doesn’t know which mail client you prefer, but you can tell it by setting the ‘read-mail-command’ variable:
;; If you're using rmail (setq read-mail-command 'rmail) ;; Or if you're using Gnus: (setq read-mail-command 'gnus) ;; Or MH-E: (setq read-mail-command 'mh-nmail)
There’s a corresponding variable for writing mail: ‘mail-user-agent’, which tells Emacs which “compose” window should appear when you activate a “Mailto” link:
;; If you prefer rmail (setq mail-user-agent 'sendmail-user-agent) ;; Or GNUS (setq mail-user-agent 'gnus-user-agent) ;; Or MH-E (setq mail-user-agent 'mh-e-user-agent)