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:

Disclaimer: The ‘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 <>
send: -mts sendmail/pipe -sendmail /usr/bin/msmtp
inc: -host -user

If you would like ‘inc’ to store your password, create a file named `~/.netrc’ that contains:

  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

auth     on
password p4ssw0rd

account default : 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:

About the documentation

MH-E has it’s own InfoMode documentation which comes with Emacs. The most recent version is 8.0 which is now being kept in sync with the released version of the software. [1]

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.

Further Configuration

The .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:

 mail-user-agent 'mh-e-user-agent
 read-mail-command 'mh-nmail)

Multiple Accounts & Gmail

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 WITH_GNUTLS=YES flag.


(setq mh-send-uses-spost-flag t)
(setq mail-user-agent 'mh-e-user-agent)


sendmail: /home/username/
mts: sendmail
masquerade: draft_from


# 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 with proto POP3
  user 'username' password 'userpass'
poll with proto POP3
  user 'username' password 'userpass' options ssl
  sslcertck sslcertpath /home/banan/.certs/


account yandex
auth     login
user     username
password userpass
account  gmail
port     587
auth     on
password userpass
tls      on

tls_trust_file /home/banan/.certs/ThawtePremiumServerCA.crt

Now, in the ~/Mail folder, you’ll edit the following files:

In each of these files, right before the To: line, add From: Me <>. Now we can select an account by editing the From: field in your compose buffer!

How to get gmail certificates for fetchmail

The certificates (zipped)

When certificates are in ~/.certs/, do $ c_rehash ~/.certs/


MhBiff (Website)is a mail-notification tool. MhCrypt, (Lisp:mh-crypt.el) is an utility to store the messages in an encrypted format. With a quick glance it seems this would break mh outside of MH-E.

Alternative to MhBiff

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.

 display-time-interval 10
 display-time-format ""
 display-time-default-load-average nil
 display-time-mail-face 'custom-themed

 (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 ", ")))))


Other MH Clients

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.

External Links