13

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?

1 Answer 1

6

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:

[database]
path=/full/path/to/root/of/your/mailboxes
# so Your directory structure will look like this:
#/full/path/to/root/of/your/mailboxes/{personal,work,school}/{INBOX,trash,…}/{cur,new,tmp}/

[user]
name=Your Name
[email protected]
[email protected];[email protected];…

[new]
tags=notify
ignore=*.json;*.json.bak;.lock

[search]
exclude_tags=deleted;spam;trash #if You want to exclude some tags from query results

[maildir]
synchronize_flags=true

[query]
junk=tag:trash OR tag:spam OR tag:drafts OR from:@linkedin.com
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 :)

7
  • Can you give more details about the top level of your setup? Like, offlineimap is run from a crontab? And how do you launch your mail reader? I guess you run neomutt which automatically opens a virtual notmuch folder corresponding to 'personal', which includes filtered mail from various accounts? How long does that startup take? Thanks! Aug 7, 2019 at 14:42
  • 1
    I use github.com/gauteh/lieer for syncing emails. It's probably the only tool able to do two-way labels sync. So it's mapped 1:1 GMail labels to notmuch tags (except excluded tags or labels). I'm syncing messages once per 3 minutes by cron + bind a key in neomutt so I can trigger it manually. I'm using notmuch post-new hooks for new-email notifications - because I don't care about every message, but only those labeled important and some other criteria. I took me a not negligible amount of time. But I'm taking a benefit from it since then. Also when you start you're never finished :D Aug 7, 2019 at 14:50
  • My config files and scripts are not yet under version control. But the time is coming. It'll be soon (it's matter of weeks or so) on my github profile. You can find the link in my StackExchange profile here. Aug 7, 2019 at 14:51
  • 1
    Now I see. I missed the part of question where you were asking about how long does it take to start. It starts instantly, and to load the whole archive (counting ~46k messages 3,3GB) takes 5-6s. Thanks to neomutt header caching (tokyocabinet). Aug 7, 2019 at 15:16
  • 1
    Sorry it took so long to accept your answer, @JakubJindra. At first I did not see how this would work and I did not have time to try implementing it. Now I did have some spare time and it works like a charm, thanks!
    – Octaviour
    Jan 9, 2020 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .