Postfix - 只允许以登录用户身份发送邮件

Postfix - only allow to send mail as logged in user

默认情况下,Postfix 允许在登录时以其他用户身份发送,即使是不存在的用户。

重现:

我启用了后缀 运行 STARTTLS 和身份验证。

使用 openssl s_client -starttls smtp -connect server.com:587 -crlf

连接到 MTA

使用 BASE64 中的凭据进行身份验证,接收 235 2.7.0 Authentication successful

现在,我可以设置 MAIL FROM:<somebody@server.com> 并将邮件发送到域,例如 server.com 本身。这意味着用户可以将自己伪装成其他用户。

这是预期的行为吗?我知道 DKIM 和 SPF 应该阻止来自另一个域的邮件,但仍然只能伪造他们的用户名。

如何将 Postfix 配置为仅允许在用户登录时发送邮件?

我找到了,在 main.cf 或 master.cf 中配置这些设置以使其工作:

smtpd_recipient_restrictions = reject_sender_login_mismatch,permit_sasl_authenticated

已采取描述 from the dev site

Optional restrictions that the Postfix SMTP server applies in the context of a client MAIL FROM command. See SMTPD_ACCESS_README, section "Delayed evaluation of SMTP access restriction lists" for a discussion of evaluation context and time. The default is to permit everything."