Greylisting 是一种十分有效减少垃电邮的方法,它的原理是暂时拒绝接收邮件,正常的电邮服务器当不能送出邮件时会重新尝试,这时才接收这封电邮。而发送垃圾邮件的主机因为需要发出大量的电邮,为了加快进度,当不能传送后便会放弃。
postgrey 是在 Postfix 简单实现灰名单的工具,以下是安装及设定 postgrey 的方法。
安装 postgrey:
RHEL / CentOS:
# dnf install postgrey
或
# yum install postgrey
Debian / Ubuntu:
# apt-get install postgrey
现在启动及设定开机自动执行 postgrep:
# systemctl enable postgrey
# systemctl start postgrey
# systemctl start postgrey
现在需要在 Postfix 设定使用 postgrey,开启 /etc/postfix/main.cf, 找到 smtpd_recipient_restrictions 的段落。
CentOS 默认会以 socket 的方式执行 postgrey,而 Ubuntu 则会在 port 10023 监听,需要安执行的方式设定,以下是 CentOS 的例子:
|
1 2 3 4 5 6 7 8 9 |
smtpd_recipient_restrictions = reject_invalid_hostname, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_policy_service unix:postgrey/socket, permit |
在 Ubuntu 则用类似以下设定:
|
1 2 3 4 5 6 7 8 9 |
smtpd_recipient_restrictions = reject_invalid_hostname, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_policy_service inet:127.0.0.1:10023, permit |
然后新加载 Postfix:
# systemctl reload postfix