MH-E is the Emacs frontend to MH (the Rand Mail Handler).
MH is a mail user agent (MUA) for the unix shell. Instead of being one monolithic program, it is a collection of small tools, which makes it easy to use and maintain.
This short example uses:
‘nmh’- the most popular MH implementation
‘msmtp’- For sending mail via SMTP
‘MH-E’- As the client used to manage your mail
‘inc’ command, used in this tutorial, will delete the files from your remote inbox after downloading them to your computer. Keep this in mind.
To use MH-E, you will need MH on your computer. The most popular implementation of MH is
‘nmh’, which you should be able to install from your package manager.
Once you have nmh, you will need to create a file in your home directory named
.mh_profile, that looks like this:
Path: mail Local-Mailbox: Me <firstname.lastname@example.org> send: -mts sendmail/pipe -sendmail /usr/bin/msmtp inc: -host mail.example.com -user email@example.com
‘Path’- Where MH looks for, and stores, email. Relative to the
‘Local-Mailbox’- Your “From:” field
‘send’- How mail is sent. We tell nmh to send mail with sendmail, but we specify msmtp as our sendmail program.
‘inc’- Our POP account, so MH can download mail directly from the remote server.
If you would like
‘inc’ to store your password, create a file named `~/.netrc’ that contains:
machine mail.example.com login firstname.lastname@example.org password p4ssw0rd
msmtp is a Mail Transfer Agent (MTA), which is used to send mail via SMTP. You should be able to install the
‘msmtp’ package from your computer’s package manager.
Create the file
~/.msmtp, which contains something like this:
account main port 587 tls on host mail.example.com from email@example.com auth on user firstname.lastname@example.org password p4ssw0rd account default : main
‘account’- The name of our profile (can be anything)
‘port’- The SMTP port
‘tls’- Use TLS (required by some SMTP servers)
‘host’- The address of our SMTP server
‘from’- Our email address
‘auth’- We’re using a username/password
‘user’- The username of our account
‘password’- Our email password
‘account default’- Which account to use (in this case, “main”)
Now that SMTP is configured via msmtp, we can send mail!
Start MH-E from Emacs with
M-x mh-nmail. This will open your MH inbox.
You can control mh-nmail with the following keys:
‘i’- Get new mail (with the ‘inc’ command)
‘o’- Move message to another folder
‘r’- Reply to current message
‘s’- Start writing a new email
‘F v’- Visit another folder
‘n/p’- Next / previous message in current folder
?- See a small help menu.
In many MH-E submodes, pressing
? provides a quick list of keybindings.
There is also the book by Jerry Peek: MH & nmh: Email for Users & Programmers.
.mh_profile file is the default MH configuration file, and can be used to set many different MH variables. Changes made here will effect all MH frontends.
In MH-E, you can see all the customization options by running:
M-x customize-group mh-e. This will open a CustomizingAndSaving interface.
To set MH-E as your default mail client, you can add the following to init.el:
(setq mail-user-agent 'mh-e-user-agent read-mail-command 'mh-nmail)
For this tutorial, you’ll need the following programs installed:
When you have multiple mail addresses, msmtp reads the
From: field and uses the corresponding account. msmtp should be built with the
(setq mh-send-uses-spost-flag t) (setq mail-user-agent 'mh-e-user-agent)
sendmail: /home/username/.msmtp-envelope-from.sh mts: sendmail masquerade: draft_from
#!/bin/sh # can't write "sendmail: /usr/local/bin/msmtp --read-envelope-from" # in mts.conf, so here's a little workaround. # Make msmtp read the "From:" field and to use that account: /usr/local/bin/msmtp --read-envelope-from $*
Path: Mail postproc: /usr/local/libexec/nmh/spost
poll pop.yandex.ru with proto POP3 user 'username' password 'userpass' poll pop.gmail.com with proto POP3 user 'username' password 'userpass' options ssl sslcertck sslcertpath /home/banan/.certs/
# email@example.com account yandex host smtp.yandex.ru from firstname.lastname@example.org auth login user username password userpass # email@example.com account gmail host smtp.gmail.com port 587 from firstname.lastname@example.org auth on user email@example.com password userpass tls on tls_trust_file /home/banan/.certs/ThawtePremiumServerCA.crt
Now, in the
In each of these files, right before the
To: line, add
From: Me <firstname.lastname@example.org>. Now we can select an account by editing the
From: field in your compose buffer!
When certificates are in
$ c_rehash ~/.certs/
For those who do not understand japanese well, there is another way to get mail notification: (display-time) function with some tweaks (useful in case of multiple mail folders)
;; Notification stuff: use display-time minor mode to notify about new mail ;; in mode-line, but omit time and load info. Print comma separated list ;; of folders with new mail in mode-line. (setq display-time-interval 10 display-time-format "" display-time-default-load-average nil display-time-mail-face 'custom-themed display-time-mail-function (lambda () (let ((input (shell-command-to-string "/usr/bin/flist -all")) (dirs nil) (start 0)) (while (string-match "^\\([a-z-+]*\\) *has [1-9].*$" input start) (push (match-string 1 input) dirs) (setq start (match-end 0))) (setq display-time-mail-string (mapconcat 'identity dirs ", "))))) (display-time)
Aside from Emacs’ MH-E, you can control MH through various shell commands (see the manpages for nmh and mh-chart)
Then there are the GUI clients, xmh and exmh, written in Tcl/Tk.
There’s another Emacs interface called tmh, written by ThienThiNguyen, but since it hasn’t been updated since late 1994. It has been archived at the author’s webpage.