douxian4323 2018-08-10 08:50
浏览 144

在localhost上发送电子邮件失败

Here is my code:

$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "my email";
$mail->Password = "my password";
$mail->SetFrom("example@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("example2@gmail.com");

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

it doesn't send email and throws this error message:

CLIENT -> SERVER: EHLO localhost
2018-08-10 08:45:27 CLIENT -> SERVER: AUTH LOGIN
2018-08-10 08:45:27 CLIENT -> SERVER: <credentials hidden>
2018-08-10 08:45:27 CLIENT -> SERVER: <credentials hidden>
2018-08-10 08:45:28 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs8534-5.7.14 qnkx1ftXmOKno0nsg7hE8GcJQABBOD5tKdlhHDkafCl07-nac1ZdHuBwSPvackU8MO9HbN534-5.7.14 wL4C9Cjxkmknf0s9OFWkEb0bJ5RT2WhX_jTZWvdW_5dHefiXvEwAYmQz5w7cXSjS3NbZJ5534-5.7.14 f4yqWmEo8j01hu6l2gBy4LIBheFtnm0B5UwvPFDJAyvRzdhhh4BB2Rr6nlUDPAMZCqmr1M534-5.7.14 oC3K4ztm4auxRpObbvxr-g_hSUJjNtEgeW7KvQ2N6MVLPZjBdA> Please log in via534-5.7.14 your web browser and then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 t15-v6sm11430067wrn.34 - gsmtp
SMTP Error: Could not authenticate.
2018-08-10 08:45:28 CLIENT -> SERVER: QUIT
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I`m sure the user and password are correct. Any idea what's wrong?

Noted that I'm on localhost (xampp)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀