afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 98 forks source link

Tagging by plus addressing #327

Open daurnimator opened 2 years ago

daurnimator commented 2 years ago

Many email setups deliver email to user+tag@domain to the inbox of user@domain. As said user, how can I extract that tag to a notmuch tag?

My first attempt was:

[HeaderMatchingFilter.1]
header = Delivered-To
pattern = (?P<user>[^\+]+)\+(?P<box>[^@]+)@(?P<domain>.*)
tags = +{box}

But it turns out many emails have many Delivered-To headers, and I only really want to match the first one.