Created
December 17, 2017 19:43
-
-
Save kousu/867050ee0de5dddaf1312647ddd83279 to your computer and use it in GitHub Desktop.
procmail snippet for auto-binning / auto-filtering mailing lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mailing lists | |
# | |
# This automatically sorts mail from mailing lists into folders named after the list | |
# [email protected] will go into your IMAP Lists/misc folder | |
# [email protected] will go into Lists/fanciness | |
# (if you need more specific rules, you can tweak or add a rule for your specific lists *ahead* of this rule) | |
# | |
# Now, procmail doesn't(?) have capturing groups, closest it has a capturing \/, | |
# which grabs everything from itself *to the end* of the line* of the match | |
# (thanks https://serverfault.com/questions/660159/procmail-recipe-with-capturing-group/660571); | |
# so how this rule works is by grabbing the list-post header, which is supposed to be part of the email standards, | |
# and extracting the name of the mailing list *before* the domain | |
# (i.e. everything after the mailto: and before the first @, that's what [^\@]* means) | |
# and puts that into $MATCH; | |
# .Lists.$MATCH is because, for some reason, at least with Dovecot, mail subfolders are separated by . not by / | |
:0 | |
* ^List-Post: <mailto:\/[^\@]* | |
.Lists.$MATCH/ | |
# ref: https://people.dsv.su.se/~jpalme/ietf/mail-headers/mail-headers.html | |
# ref: * ^FROM_DAEMON is a built in procmail rule meant to capture anything that looks like a mailing list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment