Diff: MuttFastmailMailappMac

Differences between current version and previous revision of MuttFastmailMailappMac.

Other diffs: Previous Major Revision, Previous Author

Newer page: version 9 Last edited on February 29, 2012 6:24 pm by PhilHollenback
Older page: version 8 Last edited on February 23, 2012 7:17 pm by PhilHollenback Revert
@@ -299,32 +299,4 @@
 messages quickly? Use mutt. Need to deal with lots of graphics or 
 HTML-formatted mail? Use Mail.app. On the road? Access your mail with 
 the ~FastMail web interface. No matter what mechanism you use, your 
 messages remain in one location. 
-<?plugin RawHtml  
-var idcomments_acct = '011e5665a1128cdbe79c8077f0f04353';  
-var idcomments_post_id;  
-var idcomments_post_url;  
-<span id="IDCommentsPostTitle" style="display:none"></span>  
-<script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>  
-<?plugin RawHtml  
-<script type="text/javascript"><!--  
-google_ad_client = "pub-5011581245921339";  
-google_ad_width = 728;  
-google_ad_height = 90;  
-google_ad_format = "728x90_as";  
-google_ad_channel ="";  
-<script type="text/javascript"  
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  

current version

How to Use Mutt, FastMail, and Mail.app Together on Your Mac

by Philip J. Hollenback
Originally published in MacDevCenter on January 18, 2005.

In many ways, the Mac is the best of two worlds. On the one hand, you have all the beautiful GUI-based programs that the Mac has always been famous for. On the other, Mac OS X is at its heart a Unix OS, so all the command-line tools are available as well. The result is an incredibly powerful and flexible platform.

Like a growing number of users, I came to the Mac via Linux. I have been using various Linux distributions as my pr imary desktop for years. When it came time to get a laptop, I decided it was time to look at a Mac, because frankly I was tired of dealing with all the hardware issues Linux laptop users face (modems that don't work, unsupported wireless cards, and so on). The real question, however, was this: would I be able to combine my command-line environment with the graphical tools available on Mac OS X? The answer is yes, and in this article I describe one part of that integration: email.

The Tools

For years I have run my own mail server and managed my own mail. That's the mark of a real sysadmin, right? I won't deny it's a good learning experience, but I did get tired of dealing with things like spam, system upgrades, and backups. I just wanted to read my mail.

Coincidentally, I was notified that the service I used to host my personal server was going away. Thus, it was the perfect time to shop around for a new email solution.

I knew I wanted both a sophisticated web interface (for when I'm on the road) and access via the command line (for when I'm at home). On a friend's recommendation, I tried FastMail and was quickly hooked. FastMail offers a very powerful web interface, and you can also access your email with IMAP. That meant I could use any mail program that understands IMAP - which is pretty much any mail program these days.

The obvious program to use was Apple's own Mail.app. While earlier versions of Mail.app were pretty rough around the edges and lacking in features, the current version is robust and powerful. Plus, I knew that it would take advantage of all the Mac niceties like easy image and HTML mail handling.

But what about the command line? There was no way a Linux diehard like myself was going to give that up. I've been using the premier power-user mail program mutt for years. I did a little research and found that mutt ran on Mac OS X and could be easily installed via Fink. mutt supports IMAP as well, so I could see my tools were coming together.


Mail.app was already installed on my Mac, and setting up FastMail was as simple as signing up on the web site. I opted for a paid account so I could save more mail on the server. My plan was to move all my existing mailboxes to FastMail, which would require about 50MB of space. (The free FastMail account gives you only 16MB.) For a reasonable $25 per year, I got 600MB of storage on FastMail, as well as some other useful features such as SpamAssassin filtering. That was to prove very useful.

Installing mutt was a bit more work. First I had to install Fink, the free software manager for Mac OS. Fink works with the Debian package manager apt to provide easy installation of all the standard free software from the Linux world. Installing Fink was simple: I just downloaded the Fink binary installer and ran it. Make sure to follow the documentation after doing this, because setting up your environment correctly requires that you do some work. After this, installing mutt was a simple matter of running apt-get in a terminal window:

$ sudo apt-get update

(to get the latest package list) and

$ sudo apt-get install mutt

To install mutt, I knew I would need a few helpers, so I also installed aspell, urlview, lynx, and unzip using apt-get as well.



As usual, configuring the tools is the most time-consuming part of the process. Luckily, I documented the steps I had to take and can pass the savings on to you.

To configure Mail.app, go to the Mail->Preferences menu and click on the Accounts tab. Then, click on the plus sign to create a new account. Change the settings as follows:

You have to now find a way to send mail out from your system. While it's technically possible to send mail directly from your Mac, it's generally better to relay it through a server. If you have paid for an upgraded FastMail account, you can use its SMTP server as detailed here.

Alternately, if you have a .mac account, you can use that SMTP server. Finally, as a fallback, you can run a mail server on your Mac. Just be aware that this may result in problems - your mail will look much more like spam, and some consumer broadband networks block port 25.

I use Pobox.com for mail forwarding, and it provides a free SMTP server too. Many mail services provide an SMTP server, so you should be able to find something. Also, consider using SSL if your server supports it. That way, Mail.app communicates with the outgoing mail server over an encrypted channel. That probably isn't terribly important, as once your mail gets to that server, it will be unencrypted for the rest of its journey anyway.

Once you have the account basics set up, move to the Special Mailboxes tab. Select all the check boxes on this screen to ensure that Mail.app places all its special mailboxes such as Sent and Trash on the server and doesn't store them on the local system.

Under the Advanced tab, select "Automatically synchronize changed mailboxes" and use the IMAP path prefix INBOX. You will use password authentication for that, and you can turn on SSL if you wish. That will encrypt the communications between the IMAP server and Mail.app.

Note that Mail.app and FastMail use slightly different naming conventions for some folders. Mail.app saves copies of sent messages to Sent, while FastMail uses Sent Items. The easiest way to fix this is to tell Mail.app to use the FastMail folders. In Mail.app, select each folder on the server you wish to use, and go to the Mailbox->Use This Mailbox For menu. For example, select Sent Items on the FastMail server and Use This Mailbox For Sent. Here is the list of folders on each system:

Mail.app folder FastMail folder
Trash Trash
Sent Sent Items
Drafts Drafts
Junk Junk Mail

That is all you should need to do to set up Mail.app to access your FastMail account. Test by launching Mail.app and verify that you can send and receive mail.


It is possible to open IMAP folders in mutt without doing any further configuration. To test this, run mutt in a terminal window and press c to open a mailbox. Enter your Fastmail.fm mailbox in this format:


When prompted, enter your FastMail username and password. While this is good for initial testing, it would be quite cumbersome to do this every time you wanted to change mailboxes. The solution is to place your IMAP server settings in the mutt configuration file $HOME/.muttrc. If you don't have this file, create it. Add the following entries:

set imap_user=<your fastmail user>
set imap_pass=<your fastmail password>
set record=+"Sent Items"
set postponed=+Drafts
set imap_home_namespace="INBOX"
set folder="imap://mail.messagingengine.com/INBOX"
set spoolfile="imap://mail.messagingengine.com/INBOX"
set mask="."

Mutt will now go directly to your FastMail account on startup and won't ever ask for a username or password. This will also save a copy of all your sent and postponed messages on the server. This matches the settings in Mail.app (assuming you followed my instructions above) and in the FastMail web interface. This means that you can start editing a message in FastMail, save a draft, and then open it in Mail.app or mutt with no problems.

It's Working - Now What?

You are now set up to receive mail using all three applications. However, you probably can't send mail using mutt yet. The reason is that mutt, unlike many other mail programs, does not come with an integrated facility to send mail. Instead, it relies on your system mailer (sendmail). That works fine on traditional Unix systems. However, desktop computers are usually not configured with sendmail to send mail directly.

You have two choices here. The first is to configure a full mail transfer agent (MTA) such as sendmail or postfix. This is usually overkill for a desktop system because it also sets up your system to receive mail, which you probably don't need (or want). A lighter-weight alternative is a send-only sendmail replacement such as sSMTP or esmtp. I recommend esmtp because it supports SMTP authentication. You will need authentication with most SMTP servers (FastMail requires it). esmtp is currently not available via Fink, so you will need to build it from source. You can download the source from the esmtp sourceforge site. After you install the esmtp program, create the configuration file $HOME/.esmtprc containing the following (assuming you will be using the FastMail SMTP server):

hostname = mail.messagingengine.com
username = <your fastmail username>
password = <your fastmail password>

And add the following to your .muttrc:

set sendmail=/usr/local/bin/esmtp

Now mutt will hand outgoing messages off to esmtp. esmtp will then authenticate with the FastMail SMTP server and relay the message.

But What About My Address Book?

This is the one place where everything falls apart, unfortunately. There is currently no way to synchronize the address books between all three applications. The best you can do is access your Apple address book in mutt. To do this, download and install contacts (a command-line interface to the Apple address book). Then add the following to your .muttrc:

set query_command="contact -l -f%e %s"

Then press Ctrl-T to complete addresses from your Mac address book. Note that this is not a perfect solution, as it doesn't return results in exactly the format mutt expects. The fix for this would be to create a wrapper script to adjust the results. However, it's a perfectly usable mechanism.

Another alternative would be to run a regular cron job that uses contacts to build your mutt address book out of the Mac address book every night. The downside of that approach is you have to remember to never save addresses in mutt (because they will be overwritten the next time the cron job runs).

At this time, there is no way to synchronize addresses between FastMail and any other mail system. Hopefully the folks at FastMail will address this in the near future.

Further Mutt Improvements

One thing mutt lacks in comparison with other mail programs is IMAP header caching. Every time mutt needs to know something about a message on a remote system, it has to request the header again. This slows mutt down considerably (although in practice it isn't a showstopper).

A solution can be found in the unofficial mutt imap header caching patches. I have not tried these patches yet, but they seem well-supported as evidenced by the number of vendors who ship mutt with these patches preinstalled.

Another mutt improvement would be to use SSL to encrypt communication with the IMAP server. In practice, this is not a huge concern because email is not particularly secure to begin with. However, if you are concerned about this, you should rebuild mutt from source and enable this feature. (The version in Fink has SSL turned off, probably to avoid legal problems.) This seems a worthwhile avenue to explore, especially since the FastMail IMAP server supports SSL. Once you do that, it probably also makes sense to build a version of esmtp that supports SSL as well so you can encrypt all mail to and from your mail server.

Final Thoughts

IMAP is a mature and robust protocol. The power of IMAP is that it acts as a generic mail transport and synchronization mechanism. As I've demonstrated in this article, you can easily set up three different mail applications to access a common mail store using IMAP. This gives you the flexibility to switch between applications as needed (or desired). Need to process and respond to a lot of text messages quickly? Use mutt. Need to deal with lots of graphics or HTML-formatted mail? Use Mail.app. On the road? Access your mail with the FastMail web interface. No matter what mechanism you use, your messages remain in one location.

Our Founder
ToolboxClick to hide/show
RecentChanges Click to hide/show