简体   繁体   English

PHPmailer SMTP 连接()失败

[英]PHPmailer SMTP connect() failed

I'm getting this when trying to send an email.我在尝试发送电子邮件时收到此消息。

Connection: opening to smtp.163.com:25, t=300, opt=array ()
Connection: opened
SERVER -> CLIENT: 220 163.com Anti-spam GT for Coremail System (163com[20141201])
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-mail250-PIPELINING250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2Ur83fsGUCa0xDrUUUUj250-STARTTLS250 8BITMIME
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 dXNlcm5hbWU6
CLIENT -> SERVER: xxx
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: xxx=
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 Bye
Connection: closed<br>
SMTP connect() failed.
Mailer Error: SMTP connect() failed.

Code :代码 :

require 'PHPMailerAutoload.php';

$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = "smtp.mydomain.com";
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = "user@mydomain.com";
$mail->Password = "xxxxxxxx";

$mail->setFrom('user@xxx.com', 'user');
$mail->addAddress('user@xxx.com', 'user');
$mail->Subject = 'PHPMailer SMTP test';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

If you are hosting with service providers like godaddy, it wont allow you to use SMTP authentication.Kindly check through.如果您使用 Godaddy 等服务提供商托管,则不允许您使用 SMTP 身份验证。请检查。 If not, you need to check your port address.如果没有,您需要检查您的端口地址。 Try with google smtp in your localhost first.首先在您的本地主机中尝试使用 google smtp。

The issue is using a RFC ignorant mail software.问题在于使用不了解 RFC 的邮件软件。 Right here, the server is prompting the client for the username:在这里,服务器提示客户端输入用户名:

SERVER -&gt; CLIENT: 334 dXNlcm5hbWU6

Except it's doing it wrong.除非它做错了。 It's supposed to send a 334 code followed by the base64 encoded value of: Username: , which is VXNlcm5hbWU6 .它应该发送一个 334 代码,后跟 base64 编码值: Username: ,即VXNlcm5hbWU6

Instead, it's sending the base64 encoded value of username: , which is dXNlcm5hbWU6 .相反,它发送username:的 base64 编码值,即dXNlcm5hbWU6 Note the lower cased u .注意小写的u Thus, PHPMailer never sees an appropriate SMTP AUTH prompt and the authentication fails.因此,PHPMailer 永远不会看到适当的 SMTP AUTH 提示并且身份验证失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM