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

Postfix: How to accept email with valid SPF but unresolvable hostname?

· 52CE 我爱测

I have configured my Postfix to reject email sent from hosts without PTR record and hostnames that don't have A record. I found there are legitimate mail servers with valid SPF records which don't have A record for their hostname…

问题原文

原帖链接 · LinuxBabe · CC BY-SA 4.0

I have configured my Postfix to reject email sent from hosts without PTR record and hostnames that don't have A record. I found there are legitimate mail servers with valid SPF records which don't have A record for their hostname. As a result the legitimate emails were rejected.

Is there a way to configure Postfix to accept email with valid SPF record even if there's no A record for the hostname or there's no PTR record for the IP address?

社区高分解答

原帖链接 · Esa Jokinen · CC BY-SA 4.0

This could be possible if check_policy_service responded permit (from access(5) other actions) instead of neutral accept action OK vs. reject action reject. That would need modification to the SPF policy service policyd-spf.conf. Although I have never actually tried this, based on the manpage it seems that Pass condition for both HELO and MAIL FROM allows using ANY action defined in access(5). Resulting configuratoin parameters in policyd-spf.conf:

HELO_pass_restriction = permit
Mail_From_pass_restriction = permit

Now, the order of the restrictions starts to matter as SPF policy service answers:

  • reject on SPF Fail
  • permit on SPF Pass
  • neutral OK on all other conditions including errors, Softfail, Neutral and no SPF.

Then, the Postfix main.cf can have all your restrictions in this kind of order:

smtpd_recipient_restrictions =
    permit_mynetworks,

    [checks done regardless of SPF],

    check_policy_service unix:private/policy-spf,

    [checks done only if SPF didn't either Pass or Fail],

    permit

Both permit and reject are first matches mentioned in smtpd_recipient_restrictions

Restrictions are applied in the order as specified; the first restriction that matches wins

while the neutral response from any restriction causes moving to the next one.

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

资料来源与适用范围

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

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

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