PHPMailer更新问题(从5.2.9到5.2.16) [英] PHPMailer Update Issue (from 5.2.9 to 5.2.16)

查看:67
本文介绍了PHPMailer更新问题(从5.2.9到5.2.16)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHPMailer的效果很好,我已经使用了很多年了,而且还不错.我的服务器上安装了5.2.9版,并已上传了较新的5.2.16,

PHPMailer works great, I've been using it for ages and it's pretty good. I have had version 5.2.9 on my server and have got the newer, 5.2.16 uploaded,

现在我的网站存在以下问题:

Now my sites have issues of:

"SMTP错误:SMTP connect()失败."

"SMTP Error: SMTP connect() failed."

我添加了$mail->SMTPDebug = 4;,它给了我这个:

I have added $mail->SMTPDebug = 4; and it gives me this:

2016-11-15 17:18:10 Connection: opening to localhost:25, timeout=300, options=array (
                                      )
2016-11-15 17:18:10 Connection: opened
...
removed excess repetative lines
...

2016-11-15 17:18:10 SERVER -> CLIENT: 250-mail.blythnetwork.co.uk Hello www.domain.co.uk [::1]
                                      250-SIZE 52428800
                                      250-8BITMIME
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      250 HELP
2016-11-15 17:18:10 CLIENT -> SERVER: STARTTLS
2016-11-15 17:18:10 SMTP -> get_lines(): $data is ""
2016-11-15 17:18:10 SMTP -> get_lines(): $str is  "220 TLS go ahead
                                      "
2016-11-15 17:18:10 SERVER -> CLIENT: 220 TLS go ahead
2016-11-15 17:18:10 SMTP Error: Could not connect to SMTP host.
2016-11-15 17:18:10 CLIENT -> SERVER: QUIT
2016-11-15 17:18:10 SMTP -> get_lines(): $data is ""

服务器上没有其他任何更改.恢复到PHPMailer版本5.2.9可以消除此错误(并且电子邮件可以正常发送).

Nothing else has changed on the server. Reverting to PHPMailer Version 5.2.9 removes this error (and emails are sent ok).

我也尝试从5.2.9更新到5.2.14和5.2.13,并且发生相同的错误.我没有对DNS进行任何更改,并且在PHPmailer类中没有设置DKIM或其他标识符以允许版本5.2.9,但不允许版本5.2.13或5.2.16.

I have also tried to update from 5.2.9 to 5.2.14 and 5.2.13 and the same error occurs. I have made no changes to the DNS and there are no DKIM or other identifiers set in the PHPmailer classes to allow version 5.2.9 but not 5.2.13 or 5.2.16 ones.

我正在使用PHP版本5.6.2.

I'm using PHP Version 5.6.2.

关于为什么会这样的任何线索?

Any clues as to why this is so?

发送代码: (我意识到代码不是最好的,但它是我随机选择的一个旧站点,用于测试PHPMailer 5.2.16)

The sending code: (I realise the code is not the best but it's an older site I picked at random to test out PHPMailer 5.2.16)

$mail           = new PHPMailer();
//$mail->SMTPDebug=4;
$mail->Host     = "localhost";
$mail->WordWrap = 78;
$mail->isSMTP();
$mail->From     = $fromMail;
$mail->FromName = "Website: ".$name;
$mail->AddAddress($toEmail);
$mail->Subject = $member['bizname'] . " Enquiry";
$mail->Body    = $message;
if (!$mail->Send()) {  
  ...
 }

推荐答案

花了一天左右的时间问了问题,我发现答案在于PHPMailer 5.2.10中应用了更新.

After spending a day or so asking various related questions, I found the answer lies with an update applied in PHPMailer 5.2.10.

我发现,虽然我的服务器已通过TLS认证,但是使用localhost主机似乎存在问题.可能是PHPMailer可能正在尝试检查证书是否适用于localhost域,当然不是.

I found that while my server is TLS certified, there seems to be a problem with using a localhost Host; possibly that PHPMailer may be trying to check the certificate applies to localhost domain, which of course it doesn't.

我发现现在可以通过Localhost发送邮件的解决方案是使用以下方法禁用自动TLS:

I found a solution to sending mail via Localhost now is therefore to disable auto-TLS with the following:

    $mail->SMTPAutoTLS = false; 

使用此所有电子邮件现在都可以正确发送.

Using this all emails now send correctly.

注意

Bodi0所述使用SMTPAuth是最好的做法,但是我没有意识到对于localhost邮件服务器来说是 unnessecary ,因为身份验证是隐式的.

As Bodi0 stated using SMTPAuth is best practise, however I didn't realise that it is unnessecary for localhost mail servers as the authenticaton is implicit.

关于->SMTPSecure设置相关问题的此答案的评论提供了更多详细信息.

Comments on this answer to a related question about ->SMTPSecure settings gives more details.

这篇关于PHPMailer更新问题(从5.2.9到5.2.16)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆