AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-50737

avggeek's questions

Martin Hope
avggeek
Asked: 2015-08-19 01:35:35 +0800 CST

Postfix - 多个域的发件人依赖中继

  • 4

在过去的几天里,我一直在研究 SO 问题和 Postfix 文档,但没有成功找出我做错了什么。我的情况如下:

  • 我有一个运行 Postfix 的服务器,它有自己的 FQDN(DomainA)。DomainA 的邮件通过 MailGun 中继。
  • 该服务器托管多个网站域,计划现在确保这些域的邮件通过 MailGun 中继,但作为一个单独的域。这将创建单独的退回地址等。调用此 DomainB
  • 根据标头中存在的域,配置 Postfix 以选择适当的 SASL 身份验证,确保添加适当的标头。

版本信息:Debian 7 上的 Postfix 2.11.2 (Wheezy)

postconf -n 的输出:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_at_myorigin = no
append_dot_mydomain = no
biff = no
canonical_maps = regexp:/etc/postfix/canonical
canonical_classes = envelope_sender, header_sender
config_directory = /etc/postfix
inet_interfaces = localhost
inet_protocols = ipv4
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = localhost.com, localhost
myhostname = DomainA.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sender_dependent_authentication = yes
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

relayhost_map 文件内容:

@DomainA.com      [smtp.mailgun.org]:587
@DomainB.name     [smtp.mailgun.org]:587

尝试 #1 of canonical_maps -将所有电子邮件地址重新写入 sender@DomainB.name

/./ post@domainB.name

从命令行发送电子邮件时的 mail.log 输出:

    Aug 18 01:55:12 DomainA postfix/pickup[3572]: C72492A00B8: uid=0 from=<root>
    Aug 18 01:55:12 DomainA postfix/cleanup[3591]: C72492A00B8: message-id=<20150818055512.GA3580@DomainA.com>
    Aug 18 01:55:12 DomainA postfix/qmgr[3573]: C72492A00B8: from=<post@DomainB.name>, size=437, nrcpt=1 (queue active)
    Aug 18 01:55:13 DomainA postfix/smtp[3593]: C72492A00B8: to=<me@DomainB.name>, relay=smtp.mailgun.org[50.56.21.178]:587, delay=0.28, delays=0.02/0.02/0.16/0.08, dsn=2.0.0, status=sent (250 Great success)

邮件客户端收到的电子邮件标头:

Delivered-To: me@DomainB.name
Return-Path: <bounce+0a2943.d031c-me=DomainB.name@DomainA.com>
[snip]
Sender: post=DomainB.name@DomainA.com
[snip]
From: Primary Root <post@DomainB.name>
To: me@DomainB.name
Subject: test mail #5

有两件事在我看来是非常错误的:

  1. 为什么发件人地址设置为 post=DomainB.name@DomainA.com 即使 Postfix 已设置为:

    append_at_myorigin = 没有 append_dot_mydomain = 没有

  2. 由于发件人地址附加了 DomainA.com,看来 Postfix 选择使用 DomainA 的 SASL 详细信息中继邮件 - 通过查看 MailGun 仪表板上的日志确认。这导致退回地址也设置为 DomainA。

尝试 #2 的 canoncial_maps -仅以DomainB.com结尾的电子邮件地址被重新写入 email@DomainB.com

/@DomainB.name/ email@DomainB.name

.muttrc 文件设置以强制从电子邮件地址为 DomainB.com

set from="mutt@DomainB.name"
set use_from=yes
set use_envelope_from = yes

mail.log 的输出:

Aug 18 03:40:49 DomainA postfix/qmgr[8809]: 2BEB92A00D3: from=<mutt@DomainB.name>, size=441, nrcpt=1 (queue active)
Aug 18 03:40:49 DomainA postfix/smtp[8824]: 2BEB92A00D3: to=<me@DomainB.name>, relay=smtp.mailgun.org[104.130.177.23]:587, delay=0.58, delays=0.01/0.02/0.37/0.17, dsn=2.0.0, status=sent (250 Great success)

邮件客户端收到的电子邮件标头:

Delivered-To: me@DomainB.name
[snip]
Return-Path: <bounce+0a2943.d031c-me=DomainB.name@DomainA.com>
[snip]
Sender: email=DomainB.name@DomainA.com
[snip]
From: Primary Root <email@DomainB.name>
To: me@DomainB.name
Subject: test mail hdr #7
  1. 从这个测试中,我可以看到规范映射不是问题。重写发生正确。但是,Postfix 似乎无法将输出识别为有效的电子邮件地址,并附加了导致中继中断的 FQDN。

非常欢迎任何有关如何解决此问题的建议/想法!

postfix
  • 1 个回答
  • 3923 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve