As you by now well know I try to mostly live at the console (well multiple x consoles). Mutt is my mail client of choice. I’ve tried Thunderbird, Kmail, Evolution, Sylpheed, and pine. For whatever reason I feel most comfortable with mutt. I also use IMAP for both my personal and work accounts. Mutt was originally designed to deal with local mail and while it does a very good job with IMAP I don’t like how it handles multiple accounts.

In the past I have tried to make mutt “context” aware by setting up key bindings to source different account configs. While it worked for the most part, it stumbles on the folder setting. After changing folders on one account setting the folder when sourcing another account profile never seemed to work quite right.

I also tried and failed miserably to get account-hook working. I must admit I did not try very hard as I quickly realized I would get confused as to which mailbox folder was associated with which account as I have overlapping folder names.

Offlineimap is another solution that I have tried in the past. First, I don’t want to port gigs of mail around on my laptop. Second, but less of a concern was how offlineimap synchronizes mail. My mail is important, and I don’t want to accidentally wack my mailbox if something screwy happened locally.

Eventually I came to the conclusion that the best solution for me would be to use screen. I wrote a short screenrc that launched mutt with a config for my personal mail and a config for my work mail. Each of those mutt configs source a global config first. Since they are entirely seperate instances I dont have to worry about having extra settings in one or the other to clear out unused options like I did with my profile context setup. And this one actually works since there is no issue switching between folders on accounts.

After I had my screenrc ready I wrote a short bash wrapper to launch the screen session. This script (smutt) checks to see if I already have a launched screen with the name mutt and attaches to it if available. If I don’t already have a screen session named mutt then it creates a new screen.

I would love to get some feedback on what people think of this setup or how you deal with multiple imap accounts in mutt and why you like it that way. I must admit I am missing at least one thing that I use infrequently (search). Currently I just use mutt limit and / to find an email in my archives. It would be nice to have something like mairix that works over IMAP so if you know of something or have a clever solution let me know.

Here are my mutt configs so you can try out something similar.

Here is smutt my mutt wrapper.

And here is my mutt_screen config

Here is my ~/.mutt/common (common mutt config)

I use an autoformat script to strip out nested quotes. (I just realized I never bothered to modify it at all as it still has greeting matches for the authors name)

~/.mutt/bin/autotrim

And here is an example of one of my profiles.