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

Forwarding to Gmail account via Postfix: SPF record with a hard fail

· 52CE 我爱测

I run a Postfix server which forwards one address to a gmail address. # /etc/aliases localuser: [email omitted] This works since several months. But if a sender has a SPF record with a hard fail, then the forwarding does not work…

问题原文

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

I run a Postfix server which forwards one address to a gmail address.

# /etc/aliases
localuser: [email omitted]

This works since several months. But if a sender has a SPF record with a hard fail, then the forwarding does not work:

  gmail-smtp-in.l.google.com[ said: 550-5.7.26 The
    MAIL FROM domain [example.com] has an SPF record with a hard fail 550-5.7.26
    policy (-all) but it fails to pass SPF checks with the ip: 550-5.7.26
    [...]. To best protect our users from spam and 550-5.7.26
    phishing, the message has been blocked. Please visit 550-5.7.26
    https://support.google.com/mail/answer/81126#authentication for more 550
    5.7.26 information. -
    gsmtp (in reply to end of DATA command)

How can I fix this?

社区高分解答

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

As suggested in the OP's own answer, the solution is to install postsrsd to rewrite the sender's "Return‑Path: " header.

This full example on Debian 11 worked for me:

  • apt install postsrsd
  • Edit /etc/default/postsrsd:
    • Uncomment the line with SRS_EXCLUDE_DOMAINS= and add your domains, separated by space or comma:
      SRS_EXCLUDE_DOMAINS=example.com,.example.com,example.org
  • systemctl restart postsrsd
  • Edit /etc/postfix/main.cf to add
# Use postsrsd to rewrite the Return-Path: header
sender_canonical_maps = tcp:localhost:10001
sender_canonical_classes = envelope_sender
recipient_canonical_maps = tcp:localhost:10002
recipient_canonical_classes= envelope_recipient,header_recipient
  • postfix reload

The suggested additional install of the "Postfix SRS forwarding agent" Postforward may not be necessary. It wasn't for me. Check it's description to see if you need or want it.

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

资料来源与适用范围

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

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

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