Postfix and Spamassassin: How to filter spam — page 2

1 minute read

3. Make Postfix call Spamassassin

Now, we need to tell postfix to use spamassassin. In our case, spamassassin will be invoked only once postfix has finished with the email.

To tell postfix to use spamassassin, we are going to edit /etc/postfix/ and change the line:

smtp      inet  n       -       -       -       -       smtpd


smtp      inet  n       -       -       -       -       smtpd
        -o content_filter=spamassassin

and then, at the end of, let’s add:

spamassassin unix -     n       n       -       -       pipe
        user=spamd argv=/usr/bin/spamc -f -e
        /usr/sbin/sendmail -oi -f ${sender} ${recipient}

and here we go, our spam filter is setted up, we need to reload postfix settings and everything should be ready.

# /etc/init.d/postfix reload

4. Conclusion

This is an easy to set up alternative which will filter spams using spamassassin and postfix.

There is actually other way to do so (which I will cover later on), like using amavis for instance, which will use spamassassin without needing spamassassin daemon (spamd).

The presented alternative will still send all emails to their recipient (which is something I actually prefer to rejecting and dumping email spotted as spam). One can then make up rule using either its webmail or mail client, filtering all emails having subject like [***** SPAM to be moved to a specific place in the client so you can easily move them away from your precious emails, but still in the end, there will be there, so you won’t have any emails discarded because they seemed to be spammed when there actually where real important mails.

In the end, this will behave a bit like famous mail providers such as yahoo, google, hotmail … do, you will have “Bulk Mails” and “Mails”.

Hope this helped.