Centos 7 自带 postfix 服务,无需安装
如果缺少,可执行命令
yum install postfix -y
进入postfix配置文件并在其中插入一行路径
vim /etc/postfix/main.cf
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_checks
(注解:!!! 这条路径可以在/etc/postfix/access 中找到)
然后在/etc/postfix/目录下创建一个sender_checks文件
vi /etc/postfix/sender_checks
在这个文件中,每一行添加一个域名,域名后面输入OK表示将这个域名添加到白名单,域名后面添加REJECT表示将这个域名添加到黑名单
example.com REJECT
website.com OK
我们也可以将某个二级域名添加到黑名单或白名单,只要在域名前面加上一个小数点就行了
.example.com REJECT
.website.com OK
将域名的特定邮箱地址添加到黑名单
user@example.com REJECT
保存/etc/postfix/sender_checks文件,并使用postmap命令创建/etc/postfix/sender_checks.db数据库文件
postmap /etc/postfix/sender_checks.db
最后重新加载Postfix配置文件并重启:
/etc/init.d/postfix reload
/etc/init.d/postfix restart