
Protect Your Inbox with SpamAssassin
SpamAssassin is a powerful tool for filtering out unwanted spam from your email. It uses various techniques like DNS-based and Bayesian filtering, blacklists, and online databases to keep your inbox clean.
In this guide, we'll walk you through installing and configuring SpamAssassin on an Ubuntu 16.04 server, but you can use it on any Debian or Ubuntu distribution available on buycheapvps.
1. Update Your System
First things first—let's update your server:
apt-get update
2. Install SpamAssassin
With your server up to date, install SpamAssassin and its companion tool, spamc:
apt-get install spamassassin spamc -y
3. Add a User for SpamAssassin
To get SpamAssassin running, create a new user:
groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
mkdir /var/log/spamassassin
chown spamd:spamd /var/log/spamassassin
4. Configure SpamAssassin
Open the configuration file:
nano /etc/default/spamassassin
Enable SpamAssassin and automatic rule updates by setting these variables:
ENABLED=1
CRON=1
SAHOME="/var/log/spamassassin/"
OPTIONS="--create-prefs --max-children 2 --username spamd -H ${SAHOME} -s ${SAHOME}spamd.log"
Then, start the SpamAssassin service:
service spamassassin start
5. Configure Postfix to Use SpamAssassin
To filter your emails through SpamAssassin, update the Postfix configuration:
nano /etc/postfix/master.cf
Find the line:
smtp inet n - - - - smtpd
Add this at the end of the line:
-o content_filter=spamassassin
Then, add this 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}
Finally, restart Postfix to apply the changes:
service postfix restart
6. Customize SpamAssassin Rules
For maximum protection, customize your SpamAssassin rules:
nano /etc/spamassassin/local.cf
Here are a few recommended settings:
- Add Spam Header: Uncomment **rewrite_header Subject **SPAM****
- Set Spam Threshold: Uncomment required_score 5.0
- Enable Bayes Filtering: Uncomment use_bayes 1
- Enable Auto-Learning: Uncomment bayes_auto_learn 1
Save the file and restart SpamAssassin:
service spamassassin restart
7. Test Your Setup
To confirm everything is working, check the SpamAssassin log:
nano /var/log/spamassassin/spamd.log
Or send a test email and inspect the headers.
Conclusion
With SpamAssassin, you can easily keep your inbox free of spam. Plus, you can create and manage your own filtering rules for even better control.