我的 postfix 电子邮件服务器终于运行良好。
现在,我需要防止用户在客户端程序的标题中的“发件人”字段中伪造他们的电子邮件地址,因为用户可以使用它以其他用户的身份发送电子邮件,而没有经验的用户可能会认为这是真实的。
如果用户有经验,他可以检查电子邮件标题并知道发生了什么,但有没有办法阻止这种行为?
tar*_*leb 13
看看smtpd_sender_restrictions
和smtpd_sender_login_maps
设置。前者可以防止from
地址格式错误,而后者可以强制发送者地址与登录名匹配。
# Prevent malformed senders
smtpd_sender_restrictions =
reject_non_fqdn_sender # Ensure correct mail addresses
reject_unknown_sender_domain # Ensure sender address is from an existing domain
reject_authenticated_sender_login_mismatch # Check if the user is
# allowed to use this sender address
# Maps used to stop sender address forgeries.
smtpd_sender_login_maps = pcre:/etc/postfix/login_maps.pcre
Run Code Online (Sandbox Code Playgroud)
的内容login_maps.pcre
可以是
# Use this regex if your users are local users, i.e. if the login name
# is just the username, not a full mail address.
# Note that literal dots have to be backslash escaped (`\.`) to avoid
# interpretation of these dots as regex wildcard.
/^([^@+]*)(\+[^@]*)?@example\.com$/ ${1}
# If one doesn't care about subaddresses, this could be simplified to
/^(.*)@example\.com/ ${1}
# This is appropriate if you have virtual users who login with their
# full mail address as their username. Local addresses won't work, though
/^(.*)$/ ${1}
Run Code Online (Sandbox Code Playgroud)
上面的配置假设 postfix 是在支持 PCRE 的情况下编译的。在 Ubuntu/Debian 上,这需要postfix-pcre
安装软件包。
请注意,这仅在经过身份验证的用户之外的任何人都可以发送邮件时才有效。如果您允许来自未经身份验证的用户的邮件,则上述方法将无济于事并且会失败。如果是这种情况,请务必阅读 Rui F Ribeiro 的回答。
归档时间: |
|
查看次数: |
6872 次 |
最近记录: |