Automatic mail processing
Using SpamAssassin
With the xfilter command, Maildrop passes the e-mail message to another command. This can be used to filter spam through SpamAssassin.
SpamAssassin modifies the e-mail message, adding a few X-Spam- headers to the message. With an regular expression, Maildrop can move spam messages to a different folder.
- Filtering Spam: ~/.mailfilter
# Unless an external MDA already filtered the message,# let spamassassin modify the message first.# Also continue if spamassassin fails.#if( ! /^X-Spam-Flag/ ) { exception { xfilter "/usr/bin/spamassassin -x" } }# SpamAssassin leaves a X-Spam-Flag field# in the header, check for itif( /^X-Spam-Flag: YES/ ) { log "---- *SPAM* detected. " exception {# the exception clause causes maildrop to ignore errorsto "$MAILBOX/.Spam/" } }# If these other headers are found, also# move the message to the spam folder#if( ( /vdboor-remove_this/ ) \ || ( /X-Mailer: Easy Mass Mailer/ ) \ || ( /top--sites.net/ ) \ || ( /[email protected]/ ) ) { log "---- *SPAM* manually filtered header" to "$MAILBOX/.Spam/" }
Training
The filter of SpamAssassin can be trained with the sa-learn command. It needs to know which e-mail messages are considered spam, and which are normal messages (ham).
The sa-learn needs to know the folder
where the messages are stored. For Courier IMAP,
this folder location is a bit obscure.
Subfolders start with a dot,
read messages are stored in the "cur" folder,
new messages are stored in the "new" folder.
- Training the spam filter:
sa-learn --showdots --ham ~/.maildir/.codingdomain.vdboor/cur/ sa-learn --showdots --spam ~/.maildir/.Spam/cur/
Related articles
blog comments powered by Disqus