Best practices for notmuch and neomutt

Reto reto at labrat.space
Tue Mar 3 11:48:46 PST 2020


On Tue, Mar 03, 2020 at 11:13:47AM +0000, moonmaillist at firemail.cc wrote:
> I really want to know best practices or nice virtual-mailboxes, which aren't
> included in normal tutorials. Most tutorial just have 1 email address and
> only use tags like inbox, archive, deleted and spam. But there must be much
> better use cases and much more detailed notmuch queries or even hooks which
> are triggered to specific events.

I mean in the end you need to make up a system that works for you.
I personally just tag it by topic (notmuch / neomutt / distro related...)
possibilities are endless.

But the more tags you have the harder it gets to keep track and make sense of them.

I dump all mails from 3 addresses into one notmuch db.

The necessary tricks to cope with that is in neomutt

```
set sendmail="/bin/msmtp --read-envelope-from"
set use_from=yes
set reverse_name
set envelope_from=no

# special case for lists, where we aren't explicitly on the to/cc headers
reply-hook . 'unmy_hdr From:'
reply-hook '~h"Delivered-To: asdf at gmail\.com"' my_hdr from: asdf at gmail.com
reply-hook '~h"Delivered-To: xyz at stuff\.com"' my_hdr from: xyz at stuff.com
```
While that may not be the most elegant solution, at least it works.

On the notmuch side I just use a after sync script containing all the tagging
```
#first put all in the inbox
notmuch tag +inbox -- tag:new

#temporary tag which will be removed at the end
for email in ${own_adresses[@]}; do
    notmuch tag +to_me -- "to:${email} and tag:new"
done

for email in ${own_adresses[@]}; do
    notmuch tag +sent -- "from:${email} and tag:new"
done

# then remove all the non inbox stuff one by one

# filter stuff we sent from the inbox if it isn't a self message
notmuch tag -inbox -- tag:sent and not tag:to_me
notmuch tag -inbox +lists +notmuch -- to:notmuch and tag:new
# kill muted threads
notmuch search --output=threads tag:muted | xargs -r -n1 notmuch tag +muted
#get rid of old clutter from mailing lists
notmuch tag +archive -- tag:lists and date:..30d and not tag:unread
#archived stuff should not be unread
notmuch tag -unread -- tag:unread and tag:archive
#finally remove the temporary tags
notmuch tag -new -to_me -- tag:new
```

Stuff like that...
Does this help?

Greetings,
Reto


More information about the notmuch mailing list