Created
January 26, 2015 22:22
-
-
Save problame/04771dc5a0a70e7714fa to your computer and use it in GitHub Desktop.
Dovecot Antispam Configuration + Testing script
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
| plugin { | |
| # Dovecot Antispam-Plugin configuration for sa-learn | |
| # Names for mailboxes that should not be confused | |
| # i.e. only operate on mail moved in and out of the spam folder | |
| antispam_trash = Trash,"Deleted Messages" | |
| antispam_spam = Junk;Spam;SPAM | |
| # The mailtrain backend basically is a fork and execv of the | |
| # executable and arguments provided below. | |
| # Hence, the executable runs as the dovecot user, e.g. vmail | |
| antispam_backend = mailtrain | |
| antispam_mail_sendmail = /path/to/mailtrain.py | |
| antispam_mail_spam = --spam | |
| antispam_mail_notspam = --ham | |
| antispam_mail_sendmail_args = | |
| # RTFM | |
| # By appends we mean the case of mail moving when the source folder is | |
| # unknown, e.g. when you move from some other account or with tools like | |
| #offlineimap | |
| antispam_allow_append_to_spam = no | |
| } |
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
| #!/usr/local/bin/python2.7 | |
| import sys | |
| import email | |
| with open("/var/log/mailtrain.log", "a") as log: | |
| lines = sys.stdin.readlines() | |
| parser = email.FeedParser.FeedParser() | |
| msg = None | |
| for msg_line in lines: | |
| parser.feed(msg_line) | |
| msg = parser.close() | |
| log.write("%s from %s [%s]" % (str(sys.argv), msg.get("From"), msg.get("Message-ID")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment