email - Postfix中如何改写不合格地址,使本域不被自动使用

标签 email ubuntu postfix-mta

我想将 Postfix 配置为仅重写不合格的收件人电子邮件地址(即进入电子邮件收件人:部分的地址),以使用我们客户的商业域名(如 .com)而不是本地我们客户端环境的内网域,这是 Postfix 重写无效地址的默认行为。
只是在同一页面上,对我来说无效地址是不包含“@”符号的地址,因此不是有效的 SMTP 地址
另请注意,作为一个不幸的、令人困惑的情况,此客户端环境的本地 Intranet 域实际上是一个命名的 .local 域,这可能会导致未知数量的问题,因为“.local”是一个特殊用途的保留顶级域IETF 因此,虽然我认为这实际上并没有造成问题,但应该说明这一点。这在多播与单播-dns 方面引起了我们之前的问题
细节:
不合格收件人示例:山姆0161
合格收件人示例: sam0161@ClientDomain.com
本地内网域:客户端域.local
公共(public)商业领域: ClientDomain.com
后缀版本: 3.4.13
服务器操作系统: Ubuntu 20.04.4 LTS 焦点
预期行为:
命令date | mail -s "Test Email" sam0161应该发邮件到
sam0161@hostname.ClientDomain.com
命令date | mail -s "Test Email" sam0161@AnotherValidDomain.com应该发邮件到
sam0161@AnotherValidDomain.com (即它被单独留下)
实际结果:date | mail -s "Test Email" sam0161被发送到
sam0161.Hostname.localdate | mail -s "Test Email" sam0161@AnotherValidDomain.com发送到 sam0161@AnotherValidDomain.com
(注意:这部分是正确的,我们希望保持原样,我将其包括在这里只是为了背景和完整性)
为了实现这一点,我尝试了以下方法
在/etc/postfix/main.cf

  • 已配置
    mydomain = ClientDomain.com
    append_dot_mydomain = 是
    append_at_myorigin = 否
    myorigin = $我的域名
    inet_interfaces = 所有

  • 这些配置选项的逻辑由 postfix.org 中的 local_header_rewrite_clients 描述

    Rewrite message header addresses in mail from these clients and update incomplete addresses with the domain name in $myorigin or $mydomain; either don't rewrite message headers from other clients at all, or rewrite message headers and update incomplete addresses with the domain specified in the remote_header_rewrite_domain parameter.


  • 已配置
    remote_header_rewrite_domain = "clientDomain.com"

  • 逻辑将覆盖所有邮件流量以确保对其进行重写,即使在此环境和设置中,从技术上讲,它们都不应该被视为“远程”客户端。
  • 已配置
    recipient_canonical_maps = 正则表达式:/etc/postfix/recipient_canonical

  • 逻辑是通过正则表达式“强制”收件人重写。请注意,这对我来说有点奇怪,因为查找表的手动测试显示收件人应该被重写,但是当发送邮件时,收件人地址仍然显示为 sam0161.Hostname.local
    例子:/etc/postfix/recipient_canonical!/.*@.*/ @clientDomain.compostmap -q "sam0161" regexp:/etc/postfix/recipient_canonical @clientDomain.compostmap -q "sam0161@AnotherValidDomain.com" regexp:/etc/postfix/recipient_canonical(returns nothing, desired behavior)date | mail -s "Test" sam0161postfix ignores canonical mapping and sends to hostname.domain.localpostfix/local[65681]: A6E459K616: to=<sam0161@.hostname.domain.local>, relay=local, delay=0.09, delays=0.07/0/0/0.01,简而言之,看起来我无法规避将 Postfix 使用的 gethostname() 方法调用返回的“myhostname”值附加到不合格收件人的默认行为。即使我明确地重新定义逻辑以使用与本地不同的特定域,或者尝试通过规范地址重写手动强制使用不同的域。
    谁能告诉我我想做的事情是否可行?还是 Postfix 根本不允许您重写不合格的地址以使用特定域?

    最佳答案

    这已得到纠正 - 事实证明邮件客户端不是 postfix 在到达 postfix 之前将 .hostname.local 附加到流量。这意味着正则表达式逻辑永远不会评估为“真”,因为始终存在“@”符号。
    因此,解决方法是做类似的事情
    /.*@hostname.local/clientDomain.com
    毋庸置疑,这是我在故障排除方面的严重失败,假设问题始于 Postfix 并以 Postfix 结束。

    关于email - Postfix中如何改写不合格地址,使本域不被自动使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72494065/

    相关文章:

    html - iOS 邮件客户端不呈现 html 电子邮件

    Git提交失败: "assertion ` g_type_from_name (name) == 0' failed"

    python - 后缀 + Django : SMTPException: SMTP AUTH extension not supported by server

    php - 我的 php 脚本以哪个用户身份发送电子邮件?

    c# - 发送多封邮件——大型系统中使用的解决方案

    asp.net-mvc - 在 MVC 的 html5 输入模式属性中使用 "@"

    python - 属性错误: type object 'SESConnection' has no attribute 'DefaultHost

    python: os.system不执行shell命令

    R:编译问题

    email - 查找 ubuntu postfix 邮件服务器的 smtp 用户名和密码?