阅读了很多关于sendmail relay tls port 587 gmail的文章后,仍然有问题

环境是Amazon EC2,使用sendmail 8.14.4和Cyrus sasl 2.1.23运行Amazon Linux(Centos-like)。 机器有一个弹性IP地址作为域名的目标,并为其设置反向DNS。 MXlogging点在外部服务器,所以本机不处理任何传入的互联网电子邮件,只有传出。 对于所有传出的离线节点邮件,我想使用经过TLSvalidation的连接到smtp.googlemail.com。

有很多关于这种设置的教程和文章(在这个网站和它的姊妹网站上有几个),因为它似乎是一个相当普遍的处理云中电子邮件的方式。 我一直在阅读每一个我能find的,尝试不同的东西,并学习/ var / log / maillog。 但是,对于我的生活,我很难过。 这并不是说我不能通过sendmail发送邮件,也不能通过经过validation的TLS连接发送到smtp.googlelemail.com:只是我不能让sendmail通过这样的连接发送它! 我承认我是一个sendmail新手,我知道它有一个难以configuration的声誉,所以我真的花了很多时间。 但是现在我已经没有线索和想法了。

我有一个使用Zend框架(1.11)的机器上的PHP应用程序,它使用Zend_Mail_Transport_Smtp。 在传输的构造函数中,我指定了smtp.googlemail.com,端口587,tls[email protected]和密码。 来自该应用程序的电子邮件被发送舔分裂和到达与干净的标题(我还添加了TXTlogging,包括谷歌的SPF TXTlogging到域的区域文件)。

我有另一个应用程序直接使用PHP邮件,而PHP邮件依赖于sendmail。 该应用程序还能够发送邮件,在Amazon Linux AMI提供的默认sendmailconfiguration下(不通过googleemail进行中继)到达。 但是到达消息中的标题并不那么干净,至less有一点是,spf check有一个“中立”的投诉。 所以我没有被电子邮件卡住,只是我希望能够使用sendmail来更可靠地排队外发邮件,以防万一来自网站的多用户群的电子邮件(所有这些新用户Zend Framework应用程序注册帐户:-),我不希望用户查看标题和思考问题可能不太正确。

所以这里的目标只是修改现有的工作sendmailconfiguration,通过端口587连接到googlemail来转发外发邮件,就像Zend Framework应用程序没有问题一样。 然后我可以修改Zend Framework应用程序以使用sendmail来获得排队的过载保护。

我觉得有多难?

我发现的是,随着sendmailconfiguration中的变化,传出的消息总是在/ var / log / maillog中被阻塞:

"timeout waiting for input from googlemail-smtp.l.google.com. during client greeting" 

邮件然后进入邮件并停留在那里,每次失败都会被重新尝试。

这里是sendmail.cf之间的差异,通过直接发送工作和修改通过谷歌中继:

 # diff sendmail.mc-orig sendmail.mc-new 26c27,30 < dnl define(`SMART_HOST', `smtp.your.provider')dnl --- > define(`SMART_HOST', `[smtp.googlemail.com]')dnl > define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl > define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl > FEATURE(authinfo, `Hash -o /etc/mail/authinfo.db')dnl 52,53c56,59 < dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl < dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl --- > dnl # TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl > dnl # define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl > TRUST_AUTH_MECH(`PLAIN LOGIN')dnl > define(`confAUTH_MECHANISMS', `PLAIN LOGIN')dnl 

这是(卫生)模式600根拥有authinfo文件:
AuthInfo:[smtp.googlemail.com] "U:[email protected]" P:"xyzzy" "M:PLAIN"

我也开始saslauthd,编辑/usr/lib/sasl2/Sendmail.conf来读取:
pwcheck_method:saslauthd
mech_list: login plain

我没有设置任何证书,因为据我所知,如果sendmail仅在传出连接上使用TLS,则不需要它们; 而实际上端口587连接在没有安装证书的Zend Framework应用程序中工作(或者为此而运行的saslauthd)。

与中继的sendmailconfiguration一起发送消息的29级maillog如下所示:

 [31528]: q1F5dYcB031528: [email protected], size=7085, class=0, nrcpts=1, msgid=<[email protected]>, relay=nobody@localhost [31529]: NOQUEUE: connect from localhost [127.0.0.1] [31529]: AUTH: available mech=PLAIN LOGIN, allowed mech=PLAIN LOGIN [31529]: q1F5dYYY031529: Milter: no active filter [31529]: q1F5dYYY031529: --- 220 name.compute-1.internal ESMTP Sendmail 8.14.4/8.14.4; Wed, 15 Feb 2012 05:39:34 GMT [31529]: q1F5dYYY031529: <-- EHLO name.compute-1.internal [31529]: q1F5dYYY031529: --- 250-name.compute-1.internal Hello localhost [127.0.0.1], pleased to meet you [31529]: q1F5dYYY031529: --- 250-ENHANCEDSTATUSCODES [31529]: q1F5dYYY031529: --- 250-PIPELINING [31529]: q1F5dYYY031529: --- 250-8BITMIME [31529]: q1F5dYYY031529: --- 250-SIZE [31529]: q1F5dYYY031529: --- 250-DSN [31529]: q1F5dYYY031529: --- 250-ETRN [31529]: q1F5dYYY031529: --- 250-AUTH PLAIN LOGIN [31529]: q1F5dYYY031529: --- 250-DELIVERBY [31529]: q1F5dYYY031529: --- 250 HELP [31529]: q1F5dYYY031529: <-- MAIL From:<[email protected]> SIZE=7085 [email protected] [31529]: ruleset=trust_auth, [email protected], relay=localhost [127.0.0.1], reject=550 5.7.1 <[email protected]>... not authenticated [31529]: q1F5dYYY031529: --- 250 2.1.0 <[email protected]>... Sender ok [31529]: q1F5dYYY031529: <-- RCPT To:<[email protected]> [31529]: q1F5dYYY031529: --- 250 2.1.5 <[email protected]>... Recipient ok [31529]: q1F5dYYY031529: <-- DATA [31529]: q1F5dYYY031529: --- 354 Enter mail, end with "." on a line by itself [31529]: q1F5dYYY031529: from=<[email protected]>, size=7190, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1] [31529]: q1F5dYYY031529: --- 250 2.0.0 q1F5dYYY031529 Message accepted for delivery [31528]: q1F5dYcB031528: [email protected], [email protected] (99/99), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=37085, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q1F5dYYY031529 Message accepted for delivery) [31529]: q1F5dYYZ031529: <-- QUIT [31529]: q1F5dYYZ031529: --- 221 2.0.0 name.compute-1.internal closing connection [31531]: q1F5dYYY031529: SMTP outgoing connect on name.compute-1.interna [31531]: q1F5dYYY031529: timeout waiting for input from googlemail-smtp.l.google.com. during client greeting [31531]: q1F5dYYY031529: to=<[email protected]>, delay=00:05:00, xdelay=00:05:00, mailer=relay, pri=127190, relay=googlemail-smtp.l.google.com. [74.125.91.16], dsn=4.0.0, stat=Deferred: Connection timed out with googlemail-smtp.l.google.com. 

我看到“ruleset = trust_auth,… not authenticated”消息,但是除了不知道如何解决这个问题之外,我还看到紧接着一个ok消息,日志显示它正在继续尝试连接到接力,所以我认为这与超时无关……如果我错了,有人可以告诉我如何解决这个问题,那太棒了!

邮件的maillog与未经修改的configuration一起发送,不需要中继(注意“[email protected]”实际上是一个带有mxlogging的networking解决scheme服务器的地址,这就是为什么最后一行有一个relay = for netsol.net主机):

 [31425]: q1F5VtLr031425: [email protected], size=6743, class=0, nrcpts=1, msgid=<[email protected]>, relay=nobody@localhost [31426]: NOQUEUE: connect from localhost [127.0.0.1] [31426]: AUTH: available mech=PLAIN LOGIN, allowed mech=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5 [31426]: q1F5VuPd031426: Milter: no active filter [31426]: q1F5VuPd031426: --- 220 name.compute-1.internal ESMTP Sendmail 8.14.4/8.14.4; Wed, 15 Feb 2012 05:31:56 GMT [31426]: q1F5VuPd031426: <-- EHLO name.compute-1.internal [31426]: q1F5VuPd031426: --- 250-name.compute-1.internal Hello localhost [127.0.0.1], pleased to meet you [31426]: q1F5VuPd031426: --- 250-ENHANCEDSTATUSCODES [31426]: q1F5VuPd031426: --- 250-PIPELINING [31426]: q1F5VuPd031426: --- 250-8BITMIME [31426]: q1F5VuPd031426: --- 250-SIZE [31426]: q1F5VuPd031426: --- 250-DSN [31426]: q1F5VuPd031426: --- 250-ETRN [31426]: q1F5VuPd031426: --- 250-DELIVERBY [31426]: q1F5VuPd031426: --- 250 HELP [31426]: q1F5VuPd031426: <-- MAIL From:<[email protected]> SIZE=6743 [31426]: q1F5VuPd031426: --- 250 2.1.0 <[email protected]>... Sender ok [31426]: q1F5VuPd031426: <-- RCPT To:<[email protected]> [31426]: q1F5VuPd031426: --- 250 2.1.5 <[email protected]>... Recipient ok [31426]: q1F5VuPd031426: <-- DATA [31426]: q1F5VuPd031426: --- 354 Enter mail, end with "." on a line by itself [31426]: q1F5VuPd031426: from=<[email protected]>, size=6848, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1] [31426]: q1F5VuPd031426: --- 250 2.0.0 q1F5VuPd031426 Message accepted for delivery [31425]: q1F5VtLr031425: [email protected], [email protected] (99/99), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=36743, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q1F5VuPd031426 Message accepted for delivery) [31428]: q1F5VuPd031426: SMTP outgoing connect on name.compute-1.interna [31426]: q1F5VuPe031426: <-- QUIT [31426]: q1F5VuPe031426: --- 221 2.0.0 name.compute-1.internal closing connection [31428]: q1F5VuPd031426: to=<[email protected]>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=126848, relay=inbound.domain.netsolmail.net. [205.178.149.7], dsn=2.0.0, stat=Sent (OK FB/29-06630-5434B3F4) [31428]: q1F5VuPd031426: done; delay=00:00:00, ntries=1 

这是我使用telnet得到的:

 # telnet smtp.googlemail.com 587 Trying 74.125.93.16... Connected to smtp.googlemail.com. Escape character is '^]'. 220 mx.google.com ESMTP j17sm7987765qaj.9 502 5.5.1 Unrecognized command. j17sm7987765qaj.9 STARTTLS 503 5.5.1 EHLO/HELO first. j17sm7987765qaj.9 EHLO localhost 250-mx.google.com at your service, [nnn.nnn.nnn.nnn] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES STARTTLS 220 2.0.0 Ready to start TLS 

任何帮助非常感谢!

您的密码声明似乎有一个小错字,请尝试以下操作:

 AuthInfo:googlemail.com "U:[email protected]" "P:xyzzy" "M:PLAIN" AuthInfo:google.com "U:[email protected]" "P:xyzzy" "M:PLAIN" 

不要忘记运行makemap并重buildauthinfo.db:

 makemap hash authinfo < authinfo