为了防止postfix邮件服务器被人冒用,使用它来发送伪造的垃圾邮件。也为了便于 管理员进行管理,比如针对邮箱账号对外域收发信进行限制的措施。
例如这台服务器就有伪造发件人的垃圾邮件
下面就开始添加限制配置
1、打开/etc/postfix/main.cf,在配置中增加两行
smtpd_reject_unlisted_sender = yes
smtpd_sender_login_maps = mysql:/etc/postfix/mysql_sender_login_maps.cf
2、还是main.cf配置文件,在smtpd_sender_restrictions中增加reject_sender_login_mismatch,reject_authenticated_sender_login_mismatch和reject_unauthenticated_sender_login_mismatch
具体类似如下
smtpd_sender_restrictions =
check_sender_access mysql:/etc/postfix/sender_class,
permit_mynetworks,
reject_sender_login_mismatch,
reject_authenticated_sender_login_mismatch,
reject_unauthenticated_sender_login_mismatch,
permit_sasl_authenticated,
reject_invalid_hostname,
reject_non_fqdn_hostname,
reject_unknown_sender_domain,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
reject_unauth_pipelining,
reject_unauth_destination
3、 创建/etc/postfix/mysql_sender_login_maps.cf
user = root
password = 123456
hosts = 127.0.0.1
dbname = mail
query = select username from mailbox where username='%s'
4、最后重启postfix
这样邮件服务器就不能通过伪造发件人发送邮件了。