Here’s another Emacs setup guide, this time for checking your email within Emacs using a mail client mode called View Mail, or ‘vm’. Like the Emacs-w3m Web browser I went over earlier, this one is easy to use, but can be a bit tricky to set up. Here are step-by-step instructions for getting it working; advanced users can skip the mundane stuff and grab the things they need. I’m also going to cut and paste a bit from my previous tutorial on installing Emacs-w3m where steps are redundant. As usual, this worked for me, but there’s no warranty here, express or implied.
Everyone hates outdated instructions, so I’m going to include the version numbers I’m working with. This guide is for a standard installation of Ubuntu 11.04 Natty Narwhal running Emacs v23. If you’re reading this two years from the date it was written, your mileage may vary. The same is true if you’re using a non-standard Ubuntu installation, a different *buntu, or a different Linux distro altogether. Mac users can also follow along at home, but if you’re trying this on a Mac you’ll need to translate a little, and you’ll probably have to resort to Fink or similar to get ahold of the necessary packages.
Step One: Install Some Preliminary Packages
First off, open your Terminal application, as almost everything here is going to be done from the command line. Before attempting to install the software, you’ll need to make sure that you’ve got the ‘stunnel4′ package installed on your machine, which enables vm to sign into secure mail servers. If you’ve been using your Ubuntu install for awhile, it may already have been installed for another purpose or as part of another program programs. So we’ll start by checking to see if it’s already there.
% dpkg -l 'stunnel4'
If the package is missing, you’ll get a message reading ‘No packages found matching stunnel4.’ Otherwise, the system will return something more verbose, which means that the package is already installed. If you need to install it, run the following command:
% sudo apt-get install stunnel4
After this, you’re ready to proceed.
Step Two: Install View Mail
To download vm, direct your browser to https://launchpad.net/vm and select a stable version of the source code to download. As I write this, the most recent stable version is vm-8.2.0a,
but it appears to have some nasty bug reports (e.g., ‘Bug #797300: Mailbox size doubles each time it’s saved‘) [See comment from Uday Reddy on this issue]. So I’m going to go with version 8.1.93a (download page | direct download link), which I happen to know is well behaved. The directions I’m going to give are for compiling from source, so if you’re following along step by step—whichever version you choose—download the file without the trailing characters, ‘gnu23′.
Once you’ve downloaded the compressed file, move it to your home directory. Then go to your home directory in Terminal and uncompress the file there:
% cd ~
% tar -xvf vm-8.1.93a.tgz
Remember in the above instruction, and all that follow, to replace ’8.1.93′ with whatever the version number of the file you downloaded is. Now, go to the newly created vm-8.1.93a directory:
% cd vm-8.1.93a
Then run the following two commands to install vm:
% sudo make
That’s it. You don’t need to run an ‘install’ command. Next you’ll need to configure vm to work with your email account(s).
Step Three: Creating a .vm File
Create a file titled ‘.vm’ in your home directory and populate it with the following. View Mail will look for it to find your login info. I’m going to assume you’re using an IMAP connection. There are instructions elsewhere for configuring other sorts of accounts.
(setq vm-primary-inbox "imap-ssl:yourmailserver.com:993:Inbox:login:yourusername:*")
(setq vm-crash-box "~/email/inbox.crash.mbox")
Obviously you should replace ‘yourmailserver.com’ and ’yourusername’ with your real mail server and username. Note that if your inbox is called something other than ‘Inbox’, you’ll also need to change that part of the string above to reflect the mailbox you want to check. The asterisk at the end of the login string, in case you’re wondering, causes vm to prompt you for your password the first time you log in after opening Emacs.
Step Four: Changes to Your .emacs File
Finally, add the following lines to your .emacs file to inform Emacs of all the stuff you just installed. If your vm directory has a different version number or no version number, remember to make the appropriate changes.
(setq vm-stunnel-program "/usr/bin/X11/stunnel4")
A note to Mac users: Using Fink or similar, you can install a package called ‘stunnel’ on your Mac in place of ‘stunnel4′; if you’ve done this, use the following line in place of the final line of the above block:
(setq vm-stunnel-program "/sw/sbin/stunnel")
//end of note to Mac users
Finally, if you have the Emacs-w3m browser installed, adding the following line to the .emacs file will tell View Mail to use the browser to help render HTML emails, which is a nice touch.
(setq vm-mime-text/html-handler 'emacs-w3m)
That’s it! Enjoy your Emacs mail client. Here’s a handy in-depth manual for learning your way around vm. Note that the configuration I’ve provided here only allows you to receive mail. Some further setup is required to send mail.