douchui4459 2016-03-03 21:48
浏览 180

PhpMailer SMTP注意:检查连接时是否捕获了EOF

I got an issue with phpMailer, i can't send any e-mail, and it gives me this error:

2016-03-03 21:32:09 SERVER -> CLIENT: 2016-03-03 21:32:09 SMTP NOTICE: EOF caught while checking if connected 2016-03-03 21:32:09 SMTP Error: Could not authenticate. 2016-03-03 21:32:09 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Erreur : SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

This is my code :

<?php require('phpmailer/PHPMailerAutoload.php'); 
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'ssl://smtp.gmail.com';
$mail->SMTPAuth= true;
$mail->Username='myadress@gmail.com';
$mail->Password='passwordgmail';
$mail->Port = 587; 
$mail->SMTPDebug = 2; 
$mail->SMTPSecure = 'ssl';
$mail->SetFrom('myadress@gmail.com', 'Name');
$mail->AddAddress('someone@gmail.com', 'HisName');
$mail->Subject = 'Subject';
$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail    clients";
if(!$mail->Send()) {
echo 'Error : ' . $mail->ErrorInfo;
} else {
    echo 'Ok!!';
  } 
?>

I tried all the answers i found, but none of them worked so far. I also tried other ports, the 25 and 465 don't work and give me other errors. If someone could help me please it would be really nice =) . Thank you

  • 写回答

2条回答 默认 最新

  • drjtua5953 2016-03-04 07:19
    关注

    You're using SMTPSecure = 'ssl' with Port = 587. That won't work. Use ssl / 465 or tls/ 587; don't mix them up. This (and many other problems) are covered in the troubleshooting guide the error message links to.

    Also note that the ssl: prefix in your Host value will override the value in SMTPSecure, so I'd suggest you remove it from there.

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)