depicus

changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

Gleylist spammers on Ubuntu using Postfix and Postgrey

November 3, 2014 by The Man

1. Hopefully you have Postfix already installed so simply install Postgres

sudo apt-get install postgrey

2. Edit the Postfix config file /etc/postfix/main.cf and add or amend

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination, reject_unknown_sender_domain,
check_policy_service inet:127.0.0.1:10023

3. Restart Postfix and we should be good to go

sudo service postfix restart

4. To test just send yourself an email from, say Outlook.com, then check the mail.log for something like this.

postfix/smtpd: connect from dub004-omc2s7.hotmail.com[157.55.1.146]
postgrey: action=greylist, reason=new, client_name=dub004-omc2s7.hotmail.com, client_address=157.55.1.146, sender=test@outlook.com, recipient=test@example.com
postfix/smtpd[24856]: NOQUEUE: reject: RCPT from dub004-omc2s7.hotmail.com[157.55.1.146]: 450 4.2.0 <test@example.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/email.depicus.com.html; from=<test@outlook.com> to=<test@example.com> proto=ESMTP helo=
postfix/smtpd: disconnect from dub004-omc2s7.hotmail.com[157.55.1.146]