dousi5358 2017-06-27 13:48
浏览 141

php mailer smtp connect()未能通过gmail

I have tried to send mail through gmail. I have seen other people solutions but it didn't work for me. What is the problem in my code?

Here is my output error

2017-06-27 13:53:54 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP o131sm2910537wmd.26 - gsmtp 2017-06-27 13:53:54 CLIENT -> SERVER: EHLO localhost 2017-06-27 13:53:54 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [213.55.85.206]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250 SMTPUTF8 2017-06-27 13:53:54 CLIENT -> SERVER: STARTTLS 2017-06-27 13:53:55 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS SMTP Error: Could not connect to SMTP host. 2017-06-27 13:53:55 CLIENT -> SERVER: QUIT 2017-06-27 13:53:55 2017-06-27 13:53:55 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Here is the source code

date_default_timezone_set('Etc/UTC');
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "hajiman00@gmail.com";
$mail->Password = "xxxxxxx";
$mail->setFrom('hajiman00@gmail.com', 'Support From HITD');
$mail->addAddress('hjibril37@gmail.com', 'Hassen Jibril');
$mail->Subject = 'PHPMailer GMail SMTP test';
$mail->msgHTML("MUKERA 123");
$mail->AltBody = 'This is a plain-text message body';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等