PHPMailer连接SMTP成功但认证失败问题求助
PHPMailer生产环境发送邮件失败问题
问题概述
本地使用PHPMailer发送邮件功能正常,但部署到生产服务器后出现发送失败的情况。
已完成的验证操作
通过以下命令确认生产服务器到目标SMTP端口的连通性正常:
telnet smtp.partner.outlook.cn 587
代码实现
$mail = new PHPMailer(true); $mail->SMTPDebug = 4; $mail->isSMTP(); $mail->Host = 'smtp.partner.outlook.cn'; $mail->SMTPAuth = true; $mail->Username = 'xxx'; $mail->Password = 'xxx'; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; //Recipients $mail->setFrom('xxx', 'Mailer'); $mail->addAddress('xxxx', 'Me'); //Content $mail->isHTML(true); $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'; $mail->send(); echo 'Message has been sent';
错误日志
2023-02-28 09:46:41 Connection: opening to smtp.partner.outlook.cn:587, timeout=300, options=array() 2023-02-28 09:46:41 Connection: opened 2023-02-28 09:46:41 SMTP INBOUND: "220 SHXPR01CAXX.partner.outlook.cn Microsoft ESMTP MAIL Service ready at Tue, 28 Feb 2023 09:46:43 +0000" 2023-02-28 09:46:41 SERVER -> CLIENT: 220 SHXPR01CAXX.partner.outlook.cn Microsoft ESMTP MAIL Service ready at Tue, 28 Feb 2023 09:46:43 +0000 2023-02-28 09:46:41 CLIENT -> SERVER: EHLO mysite.com 2023-02-28 09:46:41 SMTP INBOUND: "250-SHXPR01CAXX.partner.outlook.cn Hello [180.167.224.181]" 2023-02-28 09:46:41 SMTP INBOUND: "250-SIZE 157286400" 2023-02-28 09:46:41 SMTP INBOUND: "250-PIPELINING" 2023-02-28 09:46:41 SMTP INBOUND: "250-DSN" 2023-02-28 09:46:41 SMTP INBOUND: "250-ENHANCEDSTATUSCODES" 2023-02-28 09:46:41 SMTP INBOUND: "250-STARTTLS" 2023-02-28 09:46:41 SMTP INBOUND: "250-8BITMIME" 2023-02-28 09:46:41 SMTP INBOUND: "250-BINARYMIME" 2023-02-28 09:46:41 SMTP INBOUND: "250-CHUNKING" 2023-02-28 09:46:41 SMTP INBOUND: "250 SMTPUTF8" 2023-02-28 09:46:41 SERVER -> CLIENT: 250- SHXPR01CAXX.partner.outlook.cn Hello [180.167.224.181]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250- 8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8 2023-02-28 09:46:41 CLIENT -> SERVER: STARTTLS 2023-02-28 09:46:41 SMTP INBOUND: "220 2.0.0 SMTP server ready" 2023-02-28 09:46:41 SERVER -> CLIENT: 220 2.0.0 SMTP server ready 2023-02-28 09:46:41 CLIENT -> SERVER: EHLO mysite.com 2023-02-28 09:51:41 SMTP -> get_lines(): select timed-out in (300 sec) 2023-02-28 09:51:41 SERVER -> CLIENT: 2023-02-28 09:51:41 SMTP ERROR: EHLO command failed: 2023-02-28 09:51:41 CLIENT -> SERVER: HELO mysite.com 2023-02-28 09:51:41 SMTP INBOUND: "" 2023-02-28 09:51:41 SERVER -> CLIENT: 2023-02-28 09:51:41 SMTP ERROR: HELO command failed: SMTP Error: Could not authenticate. 2023-02-28 09:51:41 SMTP NOTICE: EOF caught while checking if connected 2023-02-28 09:51:41 Connection: closed SMTP Error: Could not authenticate. Message could not be sent. Mailer Error: SMTP Error: Could not authenticate.SMTP server error: Called QUIT without being connected
请求帮助
已确认端口、用户名和密码均正确,搜索多日未找到相关解决方案,恳请提供解决建议,帮助实现PHPMailer发送邮件的功能。
内容的提问来源于stack exchange,提问作者checheyue
相关产品推荐
相关产品推荐

