配置 Postfix 以使用 Mailgun - 同一域内发送失败

配置 Postfix 以使用 Mailgun - 同一域内发送失败

配置

我们进行了通常的 main.cf (postfix) 中继/sasl 条目:

# Amavisd + SpamAssassin + ClamAV
#
content_filter = smtp-amavis:[127.0.0.1]:10024

# Concurrency per recipient limit.
smtp-amavis_destination_recipient_limit = 1

relayhost = [smtp.mailgun.org]:587

smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:[email protected]:password
smtp_sasl_security_options = noanonymous

这实际上运行得很好,并且邮件传递也在 Mailgun 下正确记录。

问题
如果我们在自己的域内发送电子邮件,则不会触发 Mailgun。意思是:如果 JohnDoe@我们的XYZ域名.com 向 JaneDoe@ 发送电子邮件我们的XYZ域名,则通过 postfix 发送。如果 JohnDoe@我们的XYZ域名.com 发送电子邮件至 JohnDoe@其他域名.com,它是通过 Mailgun smtp 传送和记录的。

分析
同一域内的邮件已发送,没有出现任何错误。查看收到的电子邮件的标题时,发现 postfix 甚至没有使用 Mailgun。请参阅本地主机[127.0.0.1]在第 6 行:

Subject:test - 00:11
Contact photo
From    [email protected]    Date    Mon 00:11
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from mail.ourXYZDomain.com (localhost [127.0.0.1])
    by mail.ourXYZDomain.com (Postfix) with ESMTP id 49KwDw97hggXdtN
    for <[email protected]>; Sun, 10 May 2020 20:11:12 +0000 (UTC)
Authentication-Results: mail.ourXYZDomain.com (amavisd-new); dkim=pass
    reason="pass (just generated, assumed good)"
    header.d=ourXYZDomain.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=
    ourXYZDomain.com; h=user-agent:message-id:subject:subject
    :to:from:from:date:date:content-transfer-encoding:content-type
    :content-type:mime-version; s=dkim; t=1589141471; x=1591733472;
    bh=WonWKNs0MVBQ4Md9bT3TQ0-----=; b=1lp9qX-----YE
    HQwrRVwjLjcPcP/jkjhgjghgfWisfODNZ5xHnQto5Xa
    D6/Wj8fAEpwiu8uG5Ujhugz778gjNZ8UhFXtJf2aK
    1B8iZembDuiIsjg6fKj6snRjA=
X-Virus-Scanned: amavisd-new at mail.ourXYZDomain.com
Received: from mail.ourXYZDomain.com ([127.0.0.1])
    by mail.ourXYZDomain.com (mail.ourXYZDomain.com [127.0.0.1]) (amavisd-new, port 10026)
    with ESMTP id xzds0121548c for <[email protected]>;
    Sun, 10 May 2020 20:11:11 +0000 (UTC)
Received: from _ (localhost [127.0.0.1])
    by mail.ourXYZDomain.com (Postfix) with ESMTPSA id 49KwDv54101252XdtL
    for <[email protected]>; Sun, 10 May 2020 20:11:11 +0000 (UTC)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
    format=flowed
Content-Transfer-Encoding: 7bit
Date: Mon, 11 May 2020 00:11:11 +0400
From: [email protected]
To: [email protected]
Subject: test - 00:11
Message-ID: <[email protected]>
X-Sender: [email protected]

我们无法解释这种行为。也许我们忽略了什么?

谢谢你的提示

答案1

当您从一个 mydomain 虚拟邮箱向另一个 mydomain 虚拟邮箱发送邮件时,postfix 不会将其中继到 Mailgun 并在本地传输。

您需要创建多个 Postfix 实例,其中一个实例将所有邮件中继到 Mailgun 而不进行本地投递,第二个实例将监听 25 端口以查找收入邮件并将其投递到虚拟箱。

您可以在此处找到此解决方案的解释:http://www.postfix.org/MULTI_INSTANCE_README.html

相关内容