configurationpostfix阻止PHP发送的邮件()给某些收件人

我试图阻止我的CentOS 6.5服务器发送电子邮件到某个收件人列表。 ( [email protected][email protected]等)。

我已经configuration了这样的postfix:

/etc/postfix/main.cf

 smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access 

/ etc / postfix / recipient_access

 [email protected] REJECT [email protected] REJECT 

DB通过以下方式构build:

 postmap hash:recipient_access 

postfix被重新加载

 service postfix reload 

php.ini是:

 sendmail_path = /usr/sbin/sendmail -t -i 

不幸的是,这似乎并不奏效。 如果我使用PHP邮件()发送邮件到[email protected] ,它将一如既往地交付。

我错过了什么?

  • 这是因为smtpd_*_restrictions仅适用于通过SMTP事务由smtpd守护进程接收的SMTP 。 使用sendmail命令提交的邮件通过postdrop命令在maildrop队列中排队,由pickup并直接进行cleanup

  • 您不能限制通过sendmail命令提交的邮件的收件人。

解决这个问题的唯一办法是强制你的应用程序只通过smtp事务发送邮件。

  • 您可以使用另一个像msmtp这样的sendmail脚本来通过smtp传输mail()邮件。

  • 在你的php.ini文件中安装sendmail_path之后:

     sendmail_path = /usr/local/bin/msmtp -C /etc/msmtprc -t -i 

您可能会滥用smtp_generic_maps来转移此邮件。 与你提到的其他指令不同,这个指令可以在外发邮件上运行。

虽然无法删除,但可以将其发送到不同的邮箱,然后在邮箱中对其进行适当的操作(例如暂停发送邮件的客户)。

main.cf你会有:

 smtp_generic_maps = hash:/etc/postfix/generic 

而在/etc/postfix/generic

 [email protected] [email protected] [email protected] [email protected] 

这应该发送所有这样的邮件到您的滥用信箱,让您采取行动。

好的,我根据需要使用了virtual_alias_maps。

我在这里写了这个,但基本上你必须使用virtual_alias_maps = hash:/path/to/myblacklist.txt ,它会做的。