First we need to install postgrey daemon.
Open a terminal window and enter:
OK. Service installed!
Now open /etc/init.d/postgrey with your favorite editor and find this line:
# search for this line
It means that process "postgrey" is using socket instead of tcp connection. Socket path is cruical for postfix to communicate with postgrey. CTRL (CMD) + C this path for later use!
We need to start the service and make sure, that the service will start automatically after reboot!
The postfix config part…
With your favourite editor open /etc/postfix/main.cf
… and find the
it should look something like this:
Mine smtpd_recipient_restrictions block looks like this:
If you want to whitelist some clients/recipients open this two files with your editor of choice:
For the last step all we have to do is to reload the Postfix configuration with:
Just to be sure that Postfix and Postgrey are working together check the maillog with:
… and find this line
Well done. You've just dramatically reduced the number of SPAM messages.
If you want to read more about Postgrey service, here is the link: http://projects.puremagic.com/greylisting/
Enjoy!
=================================================================
SCRIPT TO INSTALL IN CENTOS
Open a terminal window and enter:
Code:
yum install postgreyOK. Service installed!
Now open /etc/init.d/postgrey with your favorite editor and find this line:
Code:
vi /etc/init.d/postgrey# search for this line
Code:
options="--unix=/var/spool/postfix/postgrey/socket"It means that process "postgrey" is using socket instead of tcp connection. Socket path is cruical for postfix to communicate with postgrey. CTRL (CMD) + C this path for later use!
We need to start the service and make sure, that the service will start automatically after reboot!
Code:
service post grey start
chkconfig postgrey onThe postfix config part…
With your favourite editor open /etc/postfix/main.cf
Code:
vi /etc/postfix/main.cf… and find the
Code:
smtpd_recipient_restrictions =it should look something like this:
Code:
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
check_policy_service unix:/var/spool/postfix/postgrey/socket, ### Add this line. Double check the socket path!!!Mine smtpd_recipient_restrictions block looks like this:
Code:
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
check_policy_service unix:/var/spool/postfix/postgrey/socket,
reject_invalid_hostname,
reject_unauth_destination,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
reject_unauth_pipelining,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
# SPAM/black list checks
reject_rbl_client sbl-xbl.spamhaus.org,
# reject_rbl_client multi.uribl.com, ### Too many requests - payable service
reject_rbl_client dsn.rfc-ignorant.org,
reject_rbl_client dul.dnsbl.sorbs.net,
reject_rbl_client dnsbl.njabl.org,
reject_rbl_client bl.spamcop.net,
# reject_rbl_client dnsbl.sorbs.net, ### This one is blocking emails from yahoo
reject_rbl_client cbl.abuseat.org,
reject_rbl_client ix.dnsbl.manitu.net,
reject_rbl_client combined.rbl.msrbl.net,
reject_rbl_client rabl.nuclearelephant.com,
permitIf you want to whitelist some clients/recipients open this two files with your editor of choice:
Code:
vi /etc/postfix/postgrey_whitelist_clients
vi /etc/postfix/postgrey_whitelist_recipientsFor the last step all we have to do is to reload the Postfix configuration with:
Code:
service postfix reloadJust to be sure that Postfix and Postgrey are working together check the maillog with:
Code:
tail -f /var/log/maillog… and find this line
Code:
Aug 28 17:33:59 hostname
postgrey[20092]: action=greylist, reason=new,
client_name=remote.mail.server, client_address=<remote IP
address>, sender=<email@address>,
recipient=<email@address>Well done. You've just dramatically reduced the number of SPAM messages.
If you want to read more about Postgrey service, here is the link: http://projects.puremagic.com/greylisting/
Enjoy!
=================================================================
SCRIPT TO INSTALL IN CENTOS
#!/bin/sh
#
# Script to install postgrey and spamassassin, tested on Centos 6.4 and ZPanel 10.1.0
#
if which postgrey >/dev/null; then
echo "postgrey already exist"
else
echo "Installing postgrey"
yum -y install postgrey
sed -i '/^smtpd_recipient_restrictions =/ s/$/ check_policy_service inet:127.0.0.1:60000,/' /etc/zpanel/configs/postfix/main.cf
sed -i
's/options=\"--unix=\/var\/spool\/postfix\/postgrey\/socket\"/options=\"--inet=127.0.0.1:60000
--delay=150\"/g' /etc/init.d/postgrey
service postgrey start
service postfix reload
chkconfig postgrey on
echo "postgrey installed"
fi
#
if which spamassassin >/dev/null; then
echo "spamassassin already exist"
else
echo "Installing spamassassin"
yum -y install spamassassin
echo -e "\n" > /etc/mail/spamassassin/local.cf
sed -i '1s/^/required_hits 5.0\n/' /etc/mail/spamassassin/local.cf
sed -i '2s/^/report_safe 0\n/' /etc/mail/spamassassin/local.cf
sed -i '3s/^/required_score 5\n/' /etc/mail/spamassassin/local.cf
sed -i '4s/^/rewrite_header Subject ***SPAM***\n/' /etc/mail/spamassassin/local.cf
groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
chown spamd:spamd /var/log/spamassassin
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
echo -e "\nspamassassin unix - n n - - pipe flags=R user=spamd
argv=/usr/bin/spamc -e /usr/sbin/sendmail.postfix -oi -f \${sender}
\${recipient}\n" >> /etc/zpanel/configs/postfix/master.cf
/etc/init.d/postfix restart
/etc/init.d/spamassassin restart
echo "SpamAssassin installed, to test it send a mail from outside with
the subject:
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
echo "Your first email will take about 150 seconds to arrive"
fi
No comments:
Post a Comment