我正在尝试将某些电子邮件地址列入黑名单,但是我根本无法获得postfix访问权限。
有人能指出我可能没有错误吗?
添加
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/check_senders
到/ etc / postfix /中的main.cf文件
创build了/ etc / postfix / check_senders我将我的地址添加到文件中,以检查它是否正常运行此文件包含
[email protected] REJECT
创build后缀查找表
#>postmap /etc/postfix/check_senders
重新加载并重新启动postfix
#>postfix reload #>postfix restart
为了testing这个,我创build了一个名为test.php的非常基本的PHP邮件脚本
<?php $to = '[email protected]'; $subject = 'Test postfix access'; $headers = "From: My Name <" . strip_tags('[email protected]') . ">\r\n"; $headers .= "Reply-To: ". strip_tags($to) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; if (mail($to, $subject, 'Test is a test message from the server', $headers)) echo "Sent\n\r";
用文件运行
#>php test.php
我仍然收到由PHP脚本发送的电子邮件…..任何想法?
你可能在这里有两个问题:
check_sender_access
检查信封发件人地址 。 在你的PHP脚本,你只能设置“From:” – Header。 信封发送者可能是完全不同的东西(请参阅结果消息中的“返回path”标题)
如果你在与postfix相同的服务器上运行这个php脚本, smtpd_recipient_restrictions
将不会被触发。 php mail()函数默认提交一个带有sendmail二进制文件的邮件,所以不涉及smtpd。
– >问题可能不是你的后缀configuration,但你的testing与PHP。 尝试从外部邮件源发送电子邮件(如Gmail帐户),然后查看您的黑名单是否正常工作