diff options
author | makefu <root@pigstarter.de> | 2014-06-18 14:40:22 +0200 |
---|---|---|
committer | makefu <root@pigstarter.de> | 2014-06-18 14:40:22 +0200 |
commit | b120b7a856fd2f1bab21b1f03d10c469653b5695 (patch) | |
tree | 6d9362ad96c40226a79f7b01327c08008c794be6 /content/posts/remote-spamassassin.rst | |
parent | afbbc663215c48dd68d9541298c25baede257754 (diff) |
add spamassassin
Diffstat (limited to 'content/posts/remote-spamassassin.rst')
-rw-r--r-- | content/posts/remote-spamassassin.rst | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/content/posts/remote-spamassassin.rst b/content/posts/remote-spamassassin.rst new file mode 100644 index 0000000..999e28c --- /dev/null +++ b/content/posts/remote-spamassassin.rst @@ -0,0 +1,77 @@ +Using spamassassin on a remote IMAP Host +################################## +:date: 2014-04-15 14:20 +:tags: spamassassin, mutt,offlineimap,imapfilter + + +I have the fortunate situation that i have hosted mail on a trusted second party (my father) so i do not have to deal with anything mail server related. I have a domain for receiving mails and i use a wildcard address to receive all the mails. + +Until now +--------- +... I had the following setup: + + 1. Wherever i sign up with a mail address i use something like mailto://<service-domain>@<my-domain> + 2. imapfilter_ pre-sorts mails based on the signup address + 3. offlineimap_ retrieves new mails and puts them in my $HOME/Mail + 4. mutt_ + msmtp_ to read and send mails + +Everything worked fine but my imapfilter list for spam grew above the 100 entries because some of my addresses were leaked by the web service i was using. Most spam mails got sorted correctly into my Spam folder but some survived the sorting. + +Spamassassin to the rescue +-------------------------- +Everybody seems to be using spamassassin and i always thought it can only be used with procmail and real mail retrieval. Turns out isbg.py_ is what may solve all my spam problems. It logs into the imap host and filters new mails with the help of spamassassin. + + +Installation and preparation: +.. code-block:: bash + + #?/bin/sh + # install sa + aptitude install spamassassin pyzor + # enable SA, activate 'allow-tell' + sed -i -e 's#ENABLED=.*#ENABLED=1#' -e 's#OPTIONS=.*#OPTIONS="-4 --create-prefs --max-children 5 --helper-home-dir --allow-tell"#' /etc/default/spamassassin + + update-rc.d spamassassin enable + /etc/init.d/spamassassin start + + # install IMAP spam begone + pip install isbg + +Configuration and learning: +.. code-block:: bash + + #?/bin/sh + # configure SA to your liking + cat > $HOME/.spamassassin <<EOF + required_score 5.0 + report_safe 0 + use_bayes 1 + bayes_auto_learn 1 + skip_rbl_checks 0 + use_razor2 1 + use_dcc 1 + use_pyzor 1 + ok_languages en de + ok_locales en de + score SUBJ_ILLEGAL_CHARS 0 + EOF + /etc/init.d/spamassassin restart + + # make SA learn your spam folder via isbg,also save the password + isbg.py --imaphost <imap-domain> --ssl --imapuser <imap-username> --spaminbox INBOX.Spam --spamc --teachonly --learnspambox INBOX.Spam --savepw + + vim $HOME/.offlineimaprc + # change Presynchook = imapfilter to $HOME/bin/filter_mail + + cat > $HOME/bin/filter_mail <<EOF + isbg.py --verbose --imaphost <imap-domain> --ssl --imapuser <imap-username> --spaminbox INBOX.Spam --delete --expunge --noninteractive --spamc + imapfilter + EOF + # dont worry, --delete --expurge only deletes the messages from your inbox (and essentially moves them to your Spam folder) + + # create mutt macro to mark and move spam in your inbox + echo 'macro index,pager S "| sa-learn --spam\ns=INBOX.Spam\n\n" "file as Spam"' >> $HOME/.muttrc + # optional: disbale the 'press any key to continue' : + # echo 'set wait_key = no' >> $HOME/.muttrc + +After learning my >9000 spam mails in the spam folder the spamassassin bayes filter was trained pretty well. Now i was able to remove all the 'spam' rules from .imapfilter/config.lua, and it felt GREAT. |