19 responses to “[mutt] Multiple email accounts using hooks

  1. Juri

    September 13, 2010 at 4:27 PM

    Thank you,
    you saved some of my time for the initial mutt configuration with mutt’s imap support.
    Keep on.

    • kousik

      September 14, 2010 at 7:21 PM

      Glad that I could of some help. :)

  2. rEnr3n

    September 25, 2010 at 6:41 AM

    I get twelve instances of “unset: unknown variable”

    Any idea what this is? I have removed two lines of “signature=…” since I don’t have .sig files.

  3. kousik

    October 6, 2010 at 2:06 AM

    Probably the spurious ‘unset’ command was being treated as a variable in my post:
    account-hook . ‘unset imap_user unset imap_pass’

    Try it with the second ‘unset’ and let us know if it worked.

    • kousik

      October 6, 2010 at 2:06 AM

      I meant try it “without” the second ‘unset’!

  4. Brian

    November 20, 2010 at 1:03 AM

    Thanks for the rundown. I have refined it a bit. It works perfectly. Of course, you’ll have to define key-bindings for the various folders if you unset imap_check_subscribed. The mailbox screen can be reached by typing c, ?, . Also, it isn’t necessary to set record since Gmail will automatically save sent messages to [GMAIL]/Sent. Although most of the text is wrapped in this reply, said text is actually one line.

    account-hook . ‘unset imap_user ; unset imap_pass’
    account-hook ‘imaps://’ set imap_pass = password
    account-hook ‘imaps://’ set imap_pass = password

    unset folder

    mailboxes imaps://
    folder-hook ‘imaps://’ “set folder = imaps:// ; set postponed = +[Gmail]/Drafts ; unset record ; set smtp_url = smtps:// ; set smtp_pass = ‘password’ ; set from = ‘User ‘ ; set realname = ‘User’”

    mailboxes imaps://
    folder-hook ‘imaps://’ “set folder = imaps:// ; set postponed = +[Gmail]/Drafts ; unset record ; set smtp_url = smtps:// ; set smtp_pass = ‘password’ ; set from = ‘User ‘ ; set realname = ‘User’”

    • kousik

      November 26, 2010 at 7:19 PM

      Hey Brian, thanks a lot!

      You’re right about the ‘set record’ with GMail. Everything you mentioned should work perfectly. However, I just want to make a quick comment: you can set several variables with a single set command as mentioned in the text, that is,

      set smtp_url = smtps:// ; set smtp_pass = ‘password’ ; set from = ‘User ‘ ; set realname = ‘User’”


      set smtp_url = smtps://  smtp_pass = ‘password’  from = ‘User ‘ realname = ‘User’”

      are the same things.

  5. Brian

    November 20, 2010 at 1:10 AM

    Ooops! Accounts can be reached by typing c, ?, TAB.

  6. fau

    January 27, 2011 at 5:41 AM

    Actually there is better way to decrypt passwords on the fly (no temp unencrypted files, whitch can be left on disk)

    source command will read stdin instead of file when followed by “|”
    This is how I use it:

    .secrets file:
    set my_pass1=”pass1″
    set my_pass2=”pass2″

    source “gpg –textmode -d .secrets.gpg |”

    • kousik

      February 1, 2011 at 2:35 AM

      Hey, thanks! That was a nice tip!

  7. Armando

    March 31, 2011 at 8:26 AM

    I think there is a mistake: for “set imap_user” the “=” is missing, right?


    • kousik

      March 31, 2011 at 11:18 AM

      Yes, you are absolutely right! Thank you!

  8. tonybaldwin

    September 26, 2011 at 3:44 AM

    Okay, but how does this work if I set iceweasel (firefox in debian) to use mutt for mailto links
    xterm -e mutt “$1″
    can I choose which address I am sending from with the same esc-1, or esc-2 binding? Seem that will only go to the inbox.
    Or would mutt give me the option for the From: field as it would for subject, etc.?
    I currently have two muttrc files (one .muttrc, and one .guttrc, and have aliased gmx to mutt -F .guttrc, since that is mail over imap, the first being for gmail over imap), but I haven’t figure out how to allow myself a choice with mailto links.

    I had tried with
    xterm -e read -p “gmail (mutt) or gmx (gmx)? ” mailprog;
    $mailprog “$1″
    but the xterm dies as soon as I enter my choice.

    If I can use one muttrc for both accounts, as indicated here, I’m assuming this would simplify that.

    • kousik

      October 4, 2011 at 10:41 AM

      It’s a good feature to have. But I don’t know how it can be acheived. Please let me know if you found a solution. Thanks!

  9. laustmcgregor

    May 15, 2012 at 4:05 PM


    I had to replace:
    macro index 1 “y1″ # ESC+1 takes to first INBOX
    macro index 1 “c?1″

    Mutt doesn’t seem to know the “y” shortcut (mutt 1.5.21)


    March 2, 2013 at 4:43 PM

    I think this is among the most vital information for me.

    And i’m glad reading your article. But want to remark on some general things, The web site style is perfect, the articles is really nice : D. Good job, cheers

  11. don

    May 6, 2013 at 3:53 PM

    Can you go one with multiple POP3 accounts?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 35 other followers

%d bloggers like this: