Merge multiple email accounts in single view in mutt


Recently, I have started to like the Unix philosophy more and more. One of the tools that I did not yet switch over is email. Mutt seems to be a very nice, lightweight and no-nonsense solution to reading email and I would therefore like to give it a go.

There is one problem I run into however: I use multiple inboxes. There are several tutorials available on how to use mutt with multiple inboxes, but all that I could find was a way to quickly switch between the various inboxes in one instance of mutt. I would however prefer to have a single view with the email of all of my accounts combined, sorted by date and preferably color coded by account. I know of multiple apps for mobile phones that handle this use case very nicely (e.g. the Windows Phone email app), so it should be possible. I would prefer to work this way so I only have one list of emails to go through, without having to go back and forth between accounts. Does anyone know whether it is possible to achieve this kind of behavior in mutt?

Best Answer

  • This sounds like perfect use case for notmuch. With notmuch You can use virtual mailboxes in mutt (kz patch, but I'm not able to find it on the project site) or natively with neomutt. I would say neomutt has better notmuch support.

    Mailboxes must be synced localy. So You need other tool for syncing e-mails like offlineimap, isync or similar tools. You will probably want to set up post-sync hook for tagging messages (because tags are good for querying). I would recommend to sync only All mails and let notmuch to take care of everything else using tags and queries.

    Notmuch creates a xapian database. You define Your mailboxes using notmuch queries.

    To "separate" Your accounts You can bind keys f.e.: F1 - personal F2 - work, F3 - school, F4 - … to source different config files.

    Notmuch config:

    # so Your directory structure will look like this:
    name=Your Name;;…
    exclude_tags=deleted;spam;trash #if You want to exclude some tags from query results
    junk=tag:trash OR tag:spam OR tag:drafts OR
    lists=tag:Newsletters OR tag:Maillists
    personal=NOT (tag:Work OR query:lists OR query:junk)

    I use it that way. ~/.neomutt/neomuttrc.account-personal ~/.neomutt/neomuttrc.account-work ~/.neomutt/neomuttrc.account-commmon

    in each of those files I have per-account settings (signratures, PGP, S/MIME keys or even colors) + at the end of per-account config files there's source ~/.neomutt/neomuttrc.account-common with status_format and other common configuration.

    Small recap:

    1. offlineimap / isync / other tool - for e-mail synchronization
    2. offlineimap post-sync hook - to tag messages after synchronization
    3. notmuch - for tagging and querying and virtual mailboxes
    4. mutt / neomutt bindings for switching accounts or changing per account configuration

    PS: It's easy to use once You get used to it. You need to change Your mindset. It requires some time to configure everything exactly as You want to. Don't give up, it's worth the time invested :)

  • Related Question