当我配置中继系统时,sendmail 仍然通过 estmp 发送

当我配置中继系统时,sendmail 仍然通过 estmp 发送

我正在尝试配置sendmail通过外部 smtp 服务器中继邮件:

sendmail.mc

include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl
dnl # 
dnl # Default Mailer setup
define('SMART_HOST','212.227.15.142')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
FEATURE(`authinfo')dnl 
MAILER_DEFINITIONS
MAILER(`local')dnl
MAILER(`smtp')dnl

Authinfo 文件

AuthInfo:212.227.15.142 "U:[email protected]" "I:[email protected]" "P:*********" "M:LOGIN PLAIN" 

每次更改后我都会这样做:

m4 sendmail.mc > sendmail.cf
makemap hash authinfo < authinfo
make

所有命令均能顺利执行。

mail()但是当我使用php 函数发送邮件时,var/log/mail.log我收到:

(我尝试发送到****@gmx.com邮件地址)

Jul  6 09:05:06 ubuntu sendmail[63599]: w667561E063599: to=*****@gmx.com, ctladdr=********@mydomain.es (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30208, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (w66756Vp063600 Message accepted for delivery)
Jul  6 09:05:06 ubuntu sm-mta[63602]: w66756Vp063600: to=<*****@gmx.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120544, relay=mx01.gmx.net. [212.227.17.4], dsn=4.0.0, stat=Deferred: Connection refused by mx01.gmx.net.

我认为 sendmail 没有读取 smtp 凭证或者其他东西(ip 212.227.15.142(smarthost)不在日志中)。

更新

当我尝试时:

sendmail -v -s "test" [email protected] 

我获得了这个,因此我看不到我的 smtp 身份验证或智能主机 ip 的任何痕迹。

[email protected],test... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.15.2/8.15.2/Debian-3; Mon, 9 Jul 2018 17:10:23 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH PLAIN
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<[email protected]> [email protected]
250 2.1.0 <[email protected]>... Sender ok
>>> RCPT To:<[email protected]>
>>> RCPT To:<[email protected]>
>>> DATA
250 2.1.5 <[email protected]>... Recipient ok
550 5.1.1 <[email protected]>... User unknown
354 Enter mail, end with "." on a line by itself
>>> .
050 <[email protected]>... Connecting to gmail-smtp-in.l.google.com. via esmtp...
050 220 mx.google.com ESMTP j25-v6si9299388wme.67 - gsmtp
050 >>> EHLO localhost.localdomain
050 250-mx.google.com at your service, [212.145.243.67]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO localhost.localdomain
050 250-mx.google.com at your service, [212.145.243.67]
050 250-SIZE 157286400
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:<[email protected]> SIZE=274
050 250 2.1.0 OK j25-v6si9299388wme.67 - gsmtp
050 >>> RCPT To:<[email protected]>
050 >>> DATA
050 250 2.1.5 OK j25-v6si9299388wme.67 - gsmtp
050 354  Go ahead j25-v6si9299388wme.67 - gsmtp
050 >>> .
050 250 2.0.0 OK 1531149023 j25-v6si9299388wme.67 - gsmtp
050 <[email protected]>... Sent (OK 1531149023 j25-v6si9299388wme.67 - gsmtp)
250 2.0.0 w69FANdO004647 Message accepted for delivery
[email protected]... Sent (w69FANdO004647 Message accepted for delivery)
>>> RSET
250 2.0.0 Reset state
root... Using cached ESMTP connection to [127.0.0.1] via relay...
>>> MAIL From:<> SIZE=1024
250 2.1.0 <>... Sender ok
>>> RCPT To:<[email protected]>
>>> DATA
250 2.1.5 <[email protected]>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <[email protected]>... Connecting to local...
050 <[email protected]>... Sent
250 2.0.0 w69FANdQ004647 Message accepted for delivery
root... Sent (w69FANdQ004647 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection

我认为日志必须指示“通过中继”而不是“通过 esmtp”,我的配置有问题。

编辑2

出于某种原因,我必须直接修改 sendmail.cf,因为 sendmail.mc 修改和下一个“make”操作。现在 smarthost 正在工作。

答案1

日志表明中继=mx01.gmx.net。

7 月 6 日 09:05:06 ubuntu sm-mta[63602]: w66756Vp063600: to=<*****@gmx.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120544,中继=mx01.gmx.net。[212.227.17.4], dsn=4.0.0, stat=Deferred: mx01.gmx.net 拒绝连接。

它正在尝试中继,但 SMTP 服务器正在运行mx01.gmx.net不接受中继

Connection refused by mx01.gmx.net.

只需配置 mx01.gmx.net 即可允许从您的 MTA 中继。

答案2

问题是 sendmail.cf 没有通过 make 命令更新。我建议检查 sendmail.cf 内容或直接修改它。使用此命令我终于能够从 mc 创建有效的 cf 文件:

m4 sendmail.mc > sendmail.cf

相关内容