1.sudo apt-get install postgrey
2.安裝完成後,查看Log檔,的postgrey是使用哪個port號,以下紅色的字體,使用10023
Nov 11 07:42:06 ubuntu postgrey[994]: Process Backgrounded
Nov 11 07:42:06 ubuntu postgrey[994]: 2010/11/11-07:42:06 postgrey (type Net::Server::Multiplex) starting! pid(994)
Nov 11 07:42:06 ubuntu postgrey[994]: Binding to TCP port 10023 on host localhost#012
Nov 11 07:42:06 ubuntu postgrey[994]: Setting gid to "116 116"
Nov 11 07:42:06 ubuntu postgrey[994]: Setting uid to "107"
3.修改 sudo vim /etc/postfix/main.cf,加入紅色的這段。
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
check_policy_service inet:127.0.0.1:10023
4.啟動postgrey sudo /etc/init.d/postgrey
重載postfix sudo /etc/init.d/postfix reload
5.寄一封信到此郵件伺服器,查看mail.log
cat /var/log/mail.log ------------------如下所是紅色字體,當你是第一次寄到此網域的郵件,由於還未被認證,所以伺服器會發出450的訊息,要求5分鐘後再次傳遞,當你第二次傳送時,就不需要再等待5分鐘囉,因廣告郵件伺服器通常都不會再重新傳送,所以此方式為有效防止廣告信件方法之一,如果將寄件者設定在白名單內,就不用再等待5分鐘傳送
Nov 10 13:08:43 ubuntu postgrey[1437]: action=greylist, reason=new, client_name=159-14-23-185.HINET-IP.hinet.net, client_address=159-14-23-185, sender=eef@adf.cm.cn, recipient=test@oops.orz.tw
Nov 10 13:08:43 ubuntu postfix/smtpd[1507]: NOQUEUE: reject: RCPT from 159-14-23-185.HINET-IP.hinet.net[159-14-23-185]: 450 4.2.0 <test@oops.orz.tw
>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/oops.orz.tw.html; from=<eef@adf.cm.cn> to=<test@oops.orz.tw> proto=SMTP helo=<spam.iprm.com.tw>
6.設定寄件者白名單 與 收件者白名單
ls/etc/postgrey
whitelist_clients(寄件者白名單) whitelist_recipients(收件者白名單)
設定請自行參考。