我们使用exim发送邮件(通过WHMconfiguration)。 使用相同的确切configuration,似乎绝大多数时间exim发送正确的AUTH LOGIN用户名和密码,但有时省略此部分和sendgrid拒绝与以下错误:
host smtp.sendgrid.net [158.85.10.138] SMTP error from remote mail server after MAIL FROM:<info@*******.net> SIZE=2048: 550 Unauthenticated senders not allowed
挖掘它,我可以重现这个问题(不是每次,有时)与以下几点:
# exim -v **@****.com From: **@****.com To: **@****.com Subject: Test exim This is an exim test.
这些是eximconfiguration设置:
部分:AUTH
sendgrid_login: driver = plaintext public_name = LOGIN client_send = : ******** : **************
部分:ROUTERSTART
send_via_sendgrid: driver = manualroute domains = ! +local_domains transport = sendgrid_smtp route_list = "* smtp.sendgrid.net::587 byname" host_find_failed = defer no_more
部分:TRANSPORTSTART
sendgrid_smtp: driver = smtp hosts = smtp.sendgrid.net hosts_require_auth = smtp.sendgrid.net hosts_require_tls = smtp.sendgrid.net authenticated_sender_force = true
当它工作时,这是日志:
LOG: MAIN cwd=/home/** 3 args: exim -v **@****.com From: **@****.com To: **@****.com Subject: Test exim This is an exim test. LOG: MAIN <= **@****-**.com U=jf P=local S=354 T="Test exim" **@****-** [~]# LOG: MAIN cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1ZjWZy-0005re-S3 delivering 1ZjWZy-0005re-S3 Transport port=25 replaced by host-specific port=587 Connecting to smtp.sendgrid.net [198.37.144.212]:587 ... connected SMTP<< 220 ismtpd-064 ESMTP service ready SMTP>> EHLO **.****-**.com SMTP<< 250-**.***.26.157 250-SIZE 20480000 250-STARTTLS 250-AUTH PLAIN LOGIN 250-8BITMIME 250-PIPELINING 250 AUTH=PLAIN LOGIN SMTP>> STARTTLS SMTP<< 220 Begin TLS negotiation now SMTP>> EHLO **.****-**.com SMTP<< 250-**.***.26.157 250-8BITMIME 250-SIZE 20480000 250-AUTH=PLAIN LOGIN 250-AUTH PLAIN LOGIN 250 PIPELINING SMTP>> AUTH LOGIN SMTP<< 334 VXNlcm5hbWU6 SMTP>> **** SMTP<< 334 UGFzc3dvcmQ6 SMTP>> ******************** SMTP<< 235 Authentication successful. SMTP>> MAIL FROM:<**@****-**.com> SIZE=1388 AUTH=**@****-**.com SMTP>> RCPT TO:<**@****.com> SMTP>> DATA SMTP<< 250 Sender address accepted SMTP<< 250 Recipient address accepted SMTP<< 354 Continue SMTP>> writing message and terminating "." SMTP<< 250 Delivery in progress SMTP>> QUIT LOG: MAIN => **@****.com R=send_via_sendgrid T=sendgrid_smtp H=smtp.sendgrid.net [198.37.144.212] X=TLSv1.2:AES128-GCM-SHA256:128 A=sendgrid_login C="250 Delivery in progress" LOG: MAIN Completed
请特别注意SMTP>> AUTH LOGIN和下面的六个正确的行,结束于235 Authentication successful. 线。
这是一个失败:
LOG: MAIN cwd=/home/** 3 args: exim -v **@****.com From: **@****.com To: **@****.com Subject: Test exim This is an exim test. LOG: MAIN <= **@****-**.com U=jf P=local S=340 T="Test exim" **@****-** [~]# LOG: MAIN cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1ZjWjO-0006T8-Eq delivering 1ZjWjO-0006T8-Eq Transport port=25 replaced by host-specific port=587 Connecting to smtp.sendgrid.net [198.37.144.225]:587 ... connected SMTP<< 220 ismtpd-078 ESMTP service ready SMTP>> EHLO ****-**.com SMTP<< 250-**.***.157 250-SIZE 20480000 250-STARTTLS 250-AUTH PLAIN LOGIN 250-8BITMIME 250-PIPELINING 250 AUTH=PLAIN LOGIN SMTP>> STARTTLS SMTP<< 220 Begin TLS negotiation now SMTP>> EHLO ****-**.com SMTP<< 250-**.***.26.157 250-8BITMIME 250-SIZE 20480000 250-AUTH=PLAIN LOGIN 250-AUTH PLAIN LOGIN 250 PIPELINING SMTP>> MAIL FROM:<**@****-**.com> SIZE=1374 SMTP>> RCPT TO:<**@****.com> SMTP>> DATA SMTP<< 550 Cannot receive from specified address <**@****-**.com>: Unauthenticated senders not allowed SMTP<< 503 Must have sender before recipient SMTP<< 503 Must have valid receiver and originator SMTP>> QUIT LOG: MAIN ** **@****.com R=send_via_sendgrid T=sendgrid_smtp H=smtp.sendgrid.net [198.37.144.225] X=TLSv1.2:AES128-GCM-SHA256:128: SMTP error from remote mail server after MAIL FROM:<**@****-**.com> SIZE=1374: 550 Cannot receive from specified address <**@****-**.com>: Unauthenticated senders not allowed LOG: MAIN cwd=/var/spool/exim 8 args: /usr/sbin/exim -v -t -oem -oi -f <> -E1ZjWjO-0006T8-Eq LOG: MAIN <= <> R=1ZjWjO-0006T8-Eq U=mailnull P=local S=1383 T="Mail delivery failed: returning message to sender" LOG: MAIN cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1ZjWjn-0006TR-BX delivering 1ZjWjn-0006TR-BX LOG: MAIN Completed LOG: MAIN => ** <**@****-**.com> R=localuser T=local_delivery LOG: MAIN Completed
请注意SMTP>> AUTH LOGIN ,它的下列六行不被称为…?
问题是,为什么exim省略了请求的实际SMTP>> AUTH LOGIN部分,但有时候呢? 它使用相同的确切连接configuration(可以在两个日志中看到它的引用,因为R=send_via_sendgrid T=sendgrid_smtp )。
编辑2015年11月8日:
解决scheme是使用
hosts_require_auth = <; $host_address hosts_require_tls = <; $host_address
代替
hosts_require_auth = smtp.sendgrid.net hosts_require_tls = smtp.sendgrid.net
不寻常的外观<; 语法是在主机名parsing为IPv6地址的情况下(因为听起来像IPv6地址中的冒号可能会破坏其他事情)。 $ host_addressvariables用于解决主机名parsing到的IP地址发生变化的情况(例如在这种情况下,smtp.sendgrid.netparsing为多个IP,有时另一个parsing为中间进程) – I认为它可以防止它再次被查找(另见http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_smtp_transport.html )。 信用http://kb.philross.co.uk/2008/03/15/configuring-exim-to-use-gmail-as-a-smarthost/以及OP和@wurtel。
以前的答案/如何testing和重新生成::
我相信@ wurtel对IP地址更改问题的评论是正确的,因为我可以可靠地通过使用脚本来快速更改这个IP smtp.sendgrid.net解决这个IP重现此。 我也确认,在主机文件中没有任何条目的情况下,每5秒发送一封电子邮件至less每两个小时发生一次,但是当我将一个IP硬编码到/ etc / hosts中时,我花了8个小时没有发送频率的任何错误,所以这是我现在使用的临时解决方法。
这是我如何转载这个问题。 注意:这是2015年10月底的最新版本 – 如果您在尝试之后,IP可能会不同,请运行dig smtp.sendgrid.net并使用两个IP代替。
将此添加到/ etc / hosts
108.168.190.108 smtp.sendgrid.net
将其保存到PHP文件中,用您控制的电子邮件地址[email protected]。
#!/usr/local/bin/php <?php while (true) { mail('[email protected]', 'Test email deletethiswithafilter', 'test ' . time()); usleep(500000); }
把它保存到一个PHP文件中,并在上面运行时运行它。 每隔5ms-15ms,它将在两个IP地址之间切换主机文件中smtp.sendgrid.net的条目,它parsing为158.85.10.138和108.168.190.108
#!/usr/local/bin/php <?php while (true) { passthru('new_hosts_file_contents=`cat /etc/hosts | sed \'s/108.168.190.108/ip108/g\' | sed \'s/158.85.10.138/ip158/g\' | sed \'s/ip108/158.85.10.138/g\' | sed \'s/ip158/108.168.190.108/g\'`; echo "$new_hosts_file_contents" > /etc/hosts 2>&1'); usleep(10000 + rand(-5000,5000)); }