如何使用 Postfix 作为 SMTP 中继服务器来更改发件人/发件人字段以中继到 MSO365 邮箱

如何使用 Postfix 作为 SMTP 中继服务器来更改发件人/发件人字段以中继到 MSO365 邮箱

我的公司已经建立了一个 Ubuntu 22.04 服务器作为 SMTP 中继服务器,将消息中继到我们的 Exchange 在线邮件服务器。

用户帐户[电子邮件保护]已在 Exchange 上设置用于中继。我们有多个多功能打印机和 Web 服务器,它们使用 Ubuntu 服务器上的 Postfix 发送消息/警报以发送邮件。

Postfix 已在 Ubuntu 服务器上配置并正常运行。问题是,当从 Web 服务器或打印机发送消息/警报时,它会成功发送,但发件人/发件人字段始终使用[电子邮件保护]

我们希望更改发件人/发件人字段以反映发送该消息的人或应用程序。我们尝试使用header_checkssender_canonical_maps等,但均未成功。

理想情况下,需要更改发件人/来自字段以反映谁或哪个应用程序发送了该消息。

postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 3.6
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 0
mydestination = $myhostname, echo.buckingham.ac.uk, localhost.buckingham.ac.uk, , localhost
mynetworks = 127.0.0.0/8, 10.100.0.4, 10.100.0.84, 10.100.1.204, 10.100.0.5
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = [smtp.office365.com]:587
sender_dependent_default_transport_maps = hash:/etc/postfix/relay_by_sender
smtp_always_send_ehlo = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_client_restrictions = permit_mynetworks
smtpd_recipient_restrictions = permit_mynetworks
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sender_login_maps = hash:/etc/postfix/controlled_envelope_senders
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/privat

答案1

(这可能应该是一条评论但是有点长)。

用户帐户[电子邮件保护]已在 Exchange 上设置用于中继....但发件人/发件人字段始终使用[电子邮件保护]

这是Exchange Online 的工作原理

用于通过 Microsoft 365 或 Office 365 进行身份验证的帐户的电子邮件地址将显示为来自设备或应用程序的邮件的发件人。

这里最简单的解决方案是在 DNS 中配置一个新域并将其用作(后缀)原点而不是中继。

一种解决方法是使用 RFC 5233 子寻址(这样你的电子邮件就可以来自例如[电子邮件保护]使用 user:example.com 帐户)。

您可以伪造标题 FROM 以使其与信封 FROM 不同,但这会导致更多问题。

答案2

我可以为单独的域或类似的东西创建一个 catch all,将所有内容转发到 m365。您可以为此使用虚拟别名映射。然后,您可以在设备中使用任何电子邮件地址。

virtual_alias_maps = hash:/etc/postfix/virtual

/etc/postfix/virtual 文件

@yourdomain.com   [email protected]

sudo postmap /etc/postfix/virtual

sudo systemctl reload postfix

相关内容