大网数据广告活动
服务器运维问答

smtpd_recipient_restrictions works but not always

· 52CE 我爱测

I have POSTFIX set up to filter certain email addresses. The main.cf file contains: smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/blacklist, permit_mynetworks, permit_sasl_authenticated, reject_unauth_de…

问题原文

原帖链接 · Kolja · CC BY-SA 3.0

I have POSTFIX set up to filter certain email addresses. The main.cf file contains:

smtpd_recipient_restrictions =
    check_recipient_access hash:/etc/postfix/blacklist,
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    permit

When I try to send an email to one of the addresses on the blacklist, I get the error 554 5.7.1 Access denied. just as it should be. Also when I try to send with telnet the message gets blocked. However, this server has a mailing software installed which is php based and uses swiftmailer to send messages. When I try to send a message using this software, any message to one of the blocked addresses goes through.

What could be the reason for that? How can I trace it down and debug this?

已采纳解答

原帖链接 · Dan · CC BY-SA 3.0

There are two methods of sending mail if the local machine runs a smtp server.

You can use the smtp protocol (just like any other remote client), connect to localhost port 25 and do the whole smtp talk. In this case smtpd client restrictions do apply.

Or you just run the sendmail binary with appropiate arguments. In this case you do not use the smtp protocol, hence the restrictions are not enforced.

For example the php mail() function on linux will use the second method, using as default sendmail -t -i command, or whatever is configured in php.ini as sendmail_path

Swiftmailer supports both methods, so you can change the code to use smtp instead of sendmail. See here http://swiftmailer.org/docs/sending.html

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-02-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。