我正在尝试使用PHPMailer发送邮件,但是当我尝试收到类似
的错误时MEssage Could not be sent. SMTP connect() failed
当我调试代码时,我得到以下消息:
CLIENT -> SERVER: EHLO 127.0.0.1
CLIENT -> SERVER: AUTH LOGIN
CLIENT -> SERVER: dGFsYWFzaDIwMTdAc29jZXQuZWR1Lmlu
CLIENT -> SERVER: c29jZXRAMTIz
SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt5534-5.7.14 V4dQliEGa4GCkfkxZoZVAX296_Q1jP9UHhiGXQShhTqxshYg2snLu2nKW4UIhB3k4X6Kqt534-5.7.14 Q6rvXHk5aNrXU22BwfYC_VVWeFwr8-216IZQmLpq0AA9NXNaQGQHeW1ZJNQGrvUBs6f8HQ534-5.7.14 OLspMG5dlPjNzvsAGG6lHHJ7eVYFFv8sZEYvxaAkvJR1zHk27qNpB1Gc5Ld32Fbs1SpC2H534-5.7.14 981OqnvjQrzYQCbcwIwVrqfjoVQPk> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 n79sm9364629pfj.31 - gsmtp
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
以下是我尝试过的代码:
require '../phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP();
$mail->SMTPDebug = 1;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'mymail@gmail.com'; // SMTP username
$mail->Password = 'mypass';
$mail->setFrom('mymail@gmail.com', 'Mailer');
$mail->addAddress($user_email, $user_name);
$mail->Subject = 'Registration acknowledgment GTU Techfest Zone - 1';
$mail->Body = '<b>You have registerd for following events:</b>'."\r\n";
if(!$mail->send())
{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
else
{
echo "unsuccessfull".mysql_error();
}
我尝试了几种解决方案,但它无法正常工作。 我正在使用localhost.I还更改了我的xampp设置以发送邮件