📞 🇺🇸 +1 361 304 4309 📞 🇮🇳 +91 76769 02281 ✉️ [email protected]
Email Servers

How to Set Up SpamAssassin with Postfix on Ubuntu

How to Set Up SpamAssassin with Postfix on Ubuntu

SpamAssassin is the most widely-used open-source spam filter. Integrated with Postfix via Amavis, it scores incoming email and filters spam before it reaches your mailbox.

Step 1 — Install SpamAssassin and Amavis

sudo apt install amavis spamassassin clamav clamav-daemon -y
sudo systemctl enable amavis --now

Step 2 — Configure SpamAssassin

sudo nano /etc/spamassassin/local.cf
required_score 5.0
use_bayes 1
bayes_auto_learn 1
rewrite_header Subject [SPAM]

# Whitelist your domain
whitelist_from *@yourdomain.com

# Blacklist known spam sources
blacklist_from *@spammer.com

Step 3 — Configure Amavis

sudo nano /etc/amavis/conf.d/15-content_filter_mode
use strict;
@bypass_virus_checks_maps = (1);  # Keep enabled
@bypass_spam_checks_maps  = (0);  # Enable spam checking
1;

Step 4 — Connect Postfix to Amavis

sudo nano /etc/postfix/main.cf
content_filter = amavis:[127.0.0.1]:10024
sudo nano /etc/postfix/master.cf

Add at the end:

amavis unix - - - - 2 smtp
    -o smtp_data_done_timeout=1200
    -o smtp_send_xforward_command=yes
127.0.0.1:10025 inet n - - - - smtpd
    -o content_filter=
    -o local_recipient_maps=
    -o smtpd_restriction_classes=

Step 5 — Train Bayesian Filter

# Train with known spam
sa-learn --spam /path/to/spam/folder

# Train with legitimate email
sa-learn --ham /path/to/ham/folder

# Check statistics
sa-learn --dump magic

Step 6 — Restart Services

sudo systemctl restart postfix amavis spamassassin

Conclusion

SpamAssassin with Bayes filtering catches 95%+ of spam. Our team configures complete anti-spam mail server setups for production environments.

#spamassassin #postfix #anti-spam #ubuntu #email
Share this guide:
🛠️ Need Expert Help?

Don't want to do this yourself?

Our certified engineers implement this for you — correctly, securely, and within hours. Available 24/7 with 15-minute emergency response.

  • ✅ 19+ years experience
  • ✅ 60+ certified engineers
  • ✅ 1,600+ servers managed
  • ✅ 40+ countries served
  • ✅ Plans from $49/mo

Get Expert Help — Free Consultation

We respond within 4 hours · No commitment required

Please enter your name and a valid email.

No spam. Privacy Policy

Comments