if you run your own mail server you know that spam filtering sucks. i’ve been using a method called greylisting for years and have had pretty good results with it.
greylisting will temporary block an unknown mail server from delivering a message to your server by sending a “try later” response. since most spam servers are presummed to not be setup correctly, it is thought that they will not try again. when a properly setup mailserver resends the message, it will then be delivered.
to start using greylisting in ubuntu, start by installing using apt (append sudo to any command if you need too)
apt-get install postgrey
now check to see if the postgrey daemon is running
ps aux | grep postgrey
you should see a line similar to the one below
postgrey 24441 Ss Mar27 0:00 /usr/sbin/postgrey –pidfile=/var/run/postgrey.pid –daemonize –inet=10023
make sure to note the –inet=10023 part since that is the port that postgrey uses to accept connections. this can be modified in /etc/default/postgrey if you like, but for most, the default is fine.
if you want to change the default delay that postgrey will accept a second connection from a server, change –delay=300 to something that suites you and your environment.
once you have all of your settings saved, reload postfix
postfix reload
now verify that postgrey is working by sending a test email to your server (from a different server of course). then tail the log files
tail -f /var/log/mail.log
and you should see a rejection message similar to this
Mar 10 12:37:43 xxx postfix/smtpd[26327]: NOQUEUE: reject: RCPT from unknown[***]: 450 4.2.0 <***>: Recipient address rejected: Greylisted, see …
once the mail server tries again, the message will be delivered and the senders information will be stored in the database as a known sender and any new emails sent should be delivered without any delay.
Discussion