Integrated Spamassassin and Postfix MTA Setup on Ubuntu

arrowlogo

The wiki entry on the Spamassassin wiki for the simple setup with Postfix is almost there. I recently setup my 12.04 Ubuntu server with Spamassassin with Postfix and everything is working well. I had to do a few more steps to get it working. Here is what I did.

1. Create the spamfilter.sh script detailed on the wiki. Place it in /usr/bin/spamfilter.sh and chmod +x it. Ensure the newly-created /usr/bin/spamfilter.sh has correct permissions (0755), and is owned by root:root.

2. Install/confirm spamassassin is there on Ubuntu

3. Create a new user in Ubuntu “spamd” and create a home directory for it. This is where Spamassassin is going to want to put the Bayes information. It will store it in /home/spamd/.spamassassin

4. Change the /etc/postfix/master.cf first smtp line to this

and add the spamfilter entry towards the bottom of the same /etc/postfix/master.cf file

Here is what mine looks like –

spamfilter

5. Start spamd. I just started it with a

6. Restart postfix and send a few emails in and out of the server to make sure you have a working system. You should see verbose scoring in headers or, if you get spam during this time, some verbose scoring totals in the email body like below.

496spamscore20130408

7. If things are working, you can now go in a tweak some stuff. The files you might want to mess with right off the bat are the spamassassin files in /usr/share/spamassassin

usrsharespamassassin

8. I edited the contact address and you can also change the flag on what you want your threshold to be and if you want to have SA insert the scoring in the body of the message as it does by default. These options are in:

and change “report_contact” to your email address

report_contact

and there are more options detailed over at the Spamassassin wiki >>  http://wiki.apache.org/spamassassin/FrontPage

Spamassassin and Postfix working together have been great. This is a simple setup with just a few components to minimize possible configuration issues or points of failure. Hope this helps.

5 Replies to “Integrated Spamassassin and Postfix MTA Setup on Ubuntu”

  1. Thanks for this post how ever think there’s a typo in the last master.cf code:

    spamfilter
    unix – n n – – pipe
    flags=Rq user=spamd argv=/usr/bin/spamfilter.sh -oi -f ${sender} {recipient}

    Your missing a $ on the {recipient}

    so should read

    spamfilter
    unix – n n – – pipe
    flags=Rq user=spamd argv=/usr/bin/spamfilter.sh -oi -f ${sender} {recipient}

    Corrected this then it worked fine

    Hope this helps

    Phil

      1. The $ is still missing…but once I realised that, your instructions got my spamassassin working where others had failed…thanks!!

  2. Thanks for this… really helped. I’ve looked at SpamAssassin several times in the past and always given up.

    This is all working fine, but need to go one step further… what is the best way to take this and have mail marked as spam delivered to a spam folder on the server rather than to the recipient?

Leave a comment or reply