frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

SpamAssassin. Installation And Setup.

LawrenceLawrence Member


SpamAssassin is a computer program used for e-mail spam filtering. SpamAssassin uses a variety of spam-detection techniques, including DNS-based and fuzzy-checksum-based spam detection, Bayesian filtering, external programs, blacklists, and online databases. It will save your mailbox from many unwanted spam emails.

For this tutorial we are using Ubuntu 16.04 distribution, however, you should be able to use it for all Debian and Ubuntu distributions we offer on Time4VPS.


Update System

First things first. Like always, first of all, we recommend updating your server. It can be done by simply executing:

apt-get update


Installation

After our server is up to date we can start the installation. Use apt-get to install Spamassassin and spamc:

apt-get install spamassassin spamc -y

While installing you can get a message about the kernel, we are using stable kernel version 2.6.32 for OpenVZ, so you do not need to worry about that, just click OK.

Adding User

There are a few steps that has to be taken to make it fully functional. To run SpamAssassin you need to create a new user on your VPS. First, add the group spamd:

groupadd spamd

Then add the user spamd with the home directory /var/log/spamassassin:

useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd

Then create the directory /var/log/spamassassin:

mkdir /var/log/spamassassin

And change the ownership of the directory to spamd:

chown spamd:spamd /var/log/spamassassin


Setting Up

Open the SpamAssassin config file:

nano /etc/default/spamassassin

Note: If you do not have nano installed on your server, you can do it simply with the command:

apt-get install nano

To enable Spamassassin and automatic rule updates in order to get the latest spam filtering rules to find the CRON and ENABLED variables and change then to:
ENABLED=1
CRON=1
Now create a variable named SAHOME with the Spamassassin home directory:

SAHOME="/var/log/spamassassin/"

Find and change the OPTIONS variable to:
OPTIONS="--create-prefs --max-children 2 --username spamd \
-H ${SAHOME} -s ${SAHOME}spamd.log"
After setting up is complete we can start the Spamassassin daemon by using the following code:

service spamassassin start


Configuring Postfix
SpamAssassin is set up, however, emails are still not going through it. To enabling that, open Postfix config file:

nano /etc/postfix/master.cf

Find the line:

smtp inet n - - - - smtpd

And add the following to the end of the line:

-o content_filter=spamassassin

Now, Postfix will pipe the mail through SpamAssassin.

To setup after-queue content filter add the following line to the end of the file
spamassassin unix -     n       n       -       -       pipe
user=spamd argv=/usr/bin/spamc -f -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}
For the changes to take effect restart postfix:

service postfix restart


Configuration

To get the maximum use of SpamAssassin you have to create rules. Open the SpamAssassin default rules file using:

nano /etc/spamassassin/local.cf

To activate a rules uncomment line by removing the # symbol in the beginning of the line. Some line we recommend to uncomment:

rewrite_header Subject *****SPAM***** - To add a spam header to spam mail.

required_score 5.0 - Spamassassin gives a score to each mail after running different tests on it. This line marks the mail as spam if the score is more than the value specified in the rule.

use_bayes 1 - To use Bayes theorem to check mails.

bayes_auto_learn 1 - To enable Bayes auto-learning.

After adding the above details, save the file and restart spam assassin.

service spamassassin restart


Testing

To see if SpamAssassin is working, you can check the SpamAssassin log file using:

nano /var/log/spamassassin/spamd.log

or send the email from an external server and check the mail headers.


Conclusion

Using SpamAssassin, it is very easy to protect your mailbox from spammers. The best thing about SpamAssassin is that we can create rules by ourselves and manage it.
Tagged:

Comments

  • tkrahntkrahn Member
    edited April 2019
    In case you're using spamassassin for the main time4vps.eu mail server, please be advised that it has severe problems. I tried to mail you a scan of my ID as you requested for reducing "fraudulent orders" and your mail server replied:

    Reporting-MTA: dns; relay2.mail.vrmd.de
    
    Action: failed
    Final-Recipient: rfc822;[email protected]
    Status: 5.0.0
    Remote-MTA: dns; mx.serveriai.lt
    Diagnostic-Code: smtp; 550 High probability of spam
    
    I think you're going to loose customers if you reject their legit emails.



  • ReginaRegina Moderator
    Hello,

    Yes, we have SPAM filter that is helpful in stopping possible SPAM letters coming in our mailbox. However, our SPAM filter is not spamassasin based and we do check our filter everyday and check for any customer letters there.

    You can always contact us via live chat or write from another e-mail with your question.

    Have a nice day.
Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch