Since mutt seems to be all the rage these days at work, I might as well document here a few things about my .muttrc that might be useful to others.
(I recommend that you start off with the Debian or Ubuntu package for mutt since a large chunk of necessary customization work has already been done by the Debian maintainers.)
Here is how I handle two user accounts. Let's start off by listing both of these addresses so that mutt can recognize emails using these as being sent by me:
alternates "(fmarier@gmail\.com)|(francois@debian\.org)"
Now this is to allow me to change the From address within the editor, in case I forgot to set the right one before pressing 'm':
set use_from
and this one pre-fills the From address when replying to emails based on the email account that received the original mail:
set reverse_name
Here are the two settings that I'm going to change when switching to a different identity (from address and status bar display).
# default profile
set from="francois@fmarier.org"
set status_format="-%r-francois@fmarier.org: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---"
Here are the macros I use to switch from one account to the next (bound to ESC-1 and ESC-2):
macro index \e1 ":set from=francois@fmarier.org\n:set status_format=\"-%r-francois@fmarier.org: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---\"\n" "Switch to francois@fmarier.org"
macro index \e2 ":set from=francois@debian.org\n:set status_format=\"-%r-francois@debian.org: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l?]---(%s/%S)-%>-(%P)---\"\n" "Switch to francois@debian.org"
And this is the code that uses these macros to switch to the right identity automatically:
folder-hook =inbox 'push \e1oi'
folder-hook =debian-inbox 'push \e2oi'
(The 'oi' part at the end is there to restore the default sort order.)
Finally, I've got this convenient shortcut which allows me to switch to my inbox quickly and to go from one inbox to the next:
macro index I "c=inbox\n" "Switch to inbox"
folder-hook =inbox 'macro index I "c=debian-inbox\n" "Switch to debian-inbox"'
folder-hook =debian-inbox 'macro index I "c=inbox\n" "Switch to inbox"'
Next up: indexing your emails using mairix.
Nice post :-), this is a problem I was about to attempt to solve :p
Also, definitely keen on hearing about mairix (I've been thinking about a solution to this problem for a little while now ...).
If you deal a lot with profiles and templates, check out mailplate.
Also, you can have multiple alternates lines. See my alternates file.