Sendmail 无法向特定域发送电子邮件

Sendmail 无法向特定域发送电子邮件

我有一台运行 Sendmail 的服务器,可以向除我公司的电子邮件 (company1.com) 之外的所有域发送电子邮件。我已测试向 gmail 和其他电子邮件提供商发送电子邮件,没有任何问题。Sendmail 配置为使用名为 MailJet 的第三方 SMTP 中继服务。

发送到 company1.com 时,SMTP 中继未收到电子邮件,sendmail 的错误日志如下。

company1 sendmail[676194]: 396L7G6I676194: from= [email protected], size=90, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
company1 sendmail[676196]: 396L7GsW676196: <[email protected]>... User unknown
company1 sendmail[676194]: 396L7G6I676194: [email protected], delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30090, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown

当向 Gmail 发送电子邮件时,这是日志。

company1 sendmail[668643]: 396KrnqT668643: from= [email protected], size=95, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
company1 sendmail[668645]: 396KrnVI668645: from=<[email protected]>, size=337, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=company1.com [127.0.0.1]
company1 sendmail[668643]: 396KrnqT668643: [email protected], delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30095, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (396KrnVI668645 Message accepted for delivery)
company1 sendmail[668647]: STARTTLS=client, relay=[104.199.96.85]., version=TLSv1.3, verify=OK, cipher=TLS_AES_256_GCM_SHA384, bits=256/256
company1 sendmail[668647]: 396KrnVI668645: to=<[email protected]>, delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120337, relay=[104.199.96.85]. [104.199.96.85], dsn=2.0.0, stat=Sent (OK queued as 319dec48-ebc6-4f7d-a470-2c54a4091ac2)

我的域名有以下 DMARC 记录。我已将其删除,但仍然不起作用。

v=DMARC1; p=quarantine; fo=1; pct=100; [email protected]; [email protected]

我按照人们提到的步骤修改 /etc/mail/sendmail.mc 并在末尾添加以下几行:

define(`MAIL_HUB', `company1.com.')dnl
define(`LOCAL_RELAY', `company1.com.')dnl

这仍然不能解决问题。据我所知,sendmail 在向 company1.com 发送电子邮件时尝试使用自身作为中继,而不是通过第三方 smtp 中继服务器 (Mailjet)。我该如何修复这个问题并让它正常工作?

答案1

默认情况下,在域中的系统上运行的 sendmailcompany1.com会假定它是该域的电子邮件服务器,并将发往该域的邮件转发给自己,正如您所发现的那样。我相信您想要的功能是 mailertable;在您的 sendmail 配置中启用它,然后在/etc/mail/mailertable表单中包含一个条目

.company1.com:  smtp:mx.mailjet.com

“smtp”后面的内容是您的转发服务的邮件程序之一。更多详细信息请见此处:https://www.sendmail.org/~ca/email/doc8.12/cf/m4/mailertables.html

编辑:由于 Sendmail 的功能需要使用反引号来打开引号,因此我无法在注释中显示功能语法。在 M4 文件中启用 mailertable 的操作如下:

FEATURE(`mailertable')dnl

创建 mailertable 后,你还必须将其转换为 Sendmail 可以使用的形式,例如

makemap hash /etc/mail/mailertable < /etc/mail/mailertable

答案2

事实证明,服务器主机名设置为 company1.com,这导致 sendmail 强制中继到自身。将主机名更改为 server.company1.com 解决了该问题。

相关内容