Have you ever thought of an effective way to stop spam emails?
Luckily, the Postfix Dovecot SpamAssassin combination helps to protect the mailboxes from the incoming spam mails.
However, configuring mail servers with SpamAssassin may not be easy. Often the bad configuration may lead to improper spam detection too.
At Bobcares, we often get requests from our customers to configure SpamAssassin with Postfix and Dovecot as part of our Server Management Services
Today, we’ll see how our Support Engineers make use of SpamAssassin to fight against spam mails.
How we integrate Postfix Dovecot SpamAssassin
Let’s begin by checking the process to integrate SpamAssassin in Postfix and Dovecot server.
Basically, SpamAssassin is an anti-spam software. Also, this is one of the best solutions to protect the mailbox from the incoming spam mails.
Moreover, Spamassassin can scan incoming emails. Depending on the spam score Spamassassin adds headers to that email to mark it spam.
Here, let’s see how our Support Engineers install SpamAssassin with Postfix and Dovecot on Ubuntu/Debian server.
1. Initially, we install SpamAssassin packages with the following command.
apt-get install spamassassin spamc
2. Then, we set up a user account and group for spamd service.
groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
mkdir /var/log/spamassassin
chown spamd:spamd /var/log/spamassassin
3. After that, we edit /etc/default/spamassassin to configure SpamAssassin as follows.
# Change to one to enable spamd
ENABLED=1
SAHOME="/var/log/spamassassin/"
......
OPTIONS="--create-prefs --max-children 5 --helper-home-dir --username spamd \
-H ${SAHOME} -s ${SAHOME}spamd.log"
4. As the next step, we change to CRON=1 at the bottom of this file.
5. Next, we start the SpamAssassin daemon.
service spamassassin start
6. The next step is to configure Postfix to use SpamAssassin as a filter. So, we open the file /etc/postfix/master.cf. Then add the following line at 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}
Then, we restart the postfix service.
service postfix restart
7. Additionally, we configure SpamAssassin to modify emails according to spam checks. For that, we edit the configuration file /etc/spamassassin/local.cf.
Hence, we uncomment the rewrite_header line to modify the Subject lines of emails that are identified as spam. As a result, all spam emails will have a tag. Further, this helps in an easy grouping of emails.
8. Also, we configure Dovecot with a separate Spam folder. For that, Dovecot wants a Sieve interpreter plugin. This plugin helps to use Sieve to read mails. To install the plugin,
apt-get install dovecot-sieve dovecot-managesieved
And, we edit /etc/dovecot/conf.d/20-lmtp.conf file to configure dovecot to enable the sieve plugin.
protocol lmtp {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins sieve
}
9. Finally, we restart dovecot and SpamAssassin.
service dovecot restart
service spamassassin restart
That’s it. We set up SpamAssassin with Postfix and Dovecot on Ubuntu/Debian server.
How we fixed the error after configuring Postfix Dovecot SpamAssassin
From our experience in managing servers, we’ve seen customers often facing problems after configuring SpamAssassin in the Postfix Dovecot server.
Now, let’s see how our Support Engineers fixed the top errors.
Bad SpamAssassin settings
Recently, one of our customers had a problem after configuring SpamAssassin on his server. Also, he was trying to move Spam detected by SpamAssassin automatically to the junk folder on Debian. However, it did not work.
On checking, our Support Engineers found that the customer forgot to enable spamd service in the file /etc/default/spamassassin
So, we changed ENABLED=0 to 1 in the file. Finally, a restart of the mail services solved the problem.
[Having difficulty in configuring SpamAssassin? We’ll fix it for you.]
Conclusion
In short, SpamAssassin protects the mailboxes on a server using Postfix and Dovecot from incoming spam. Today, we saw how our Support Engineers configure and integrate SpamAssassin on mail server and fix related errors.
0 Comments