Я использую PHPMailer, чтобы попытаться отправить почту, используя gmail. К сожалению, получаю ошибку, которая прилагается. Перепробовал все, чтобы решить, у кого-нибудь есть идеи, что может быть не так? Я разрешил менее безопасные приложения.
2018-04-30 12:17:15 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP f29sm10891032pff.169 - gsmtp
2018-04-30 12:17:15 CLIENT -> SERVER: EHLO curtisboylan.com
2018-04-30 12:17:15 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [69.64.65.142]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250-SMTPUTF8
2018-04-30 12:17:15 CLIENT -> SERVER: STARTTLS
2018-04-30 12:17:15 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2018-04-30 12:17:15 CLIENT -> SERVER: EHLO curtisboylan.com2018-04-30 12:17:15 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [69.64.65.142]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2018-04-30 12:17:15 CLIENT -> SERVER: AUTH LOGIN
2018-04-30 12:17:15 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2018-04-30 12:17:15 CLIENT -> SERVER: <credentials hidden>
2018-04-30 12:17:15 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2018-04-30 12:17:15 CLIENT -> SERVER: <credentials hidden>
2018-04-30 12:17:15 SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbvH534-5.7.14 Po6hfzTwq4hCMvLl_DdV9aGq22R-Ak0Vu_nq3jSd95TekrsnufIKHEH5N5XE4VDyIGA9lJ534-5.7.14 zc-jKgF2YAlfTXogT_7AeKcQBnpv8_5A7P8ZpDq6OXTmtlZA3qIYH1Kp8KgrbTrrOwXwRz534-5.7.14 Qj4-AoQL0mbHuJqW7Bo4wulTCBHBjOyTkMaImncgl9sBb7Iz4_z4fo_MgPJXiMAbmG6nyo534-5.7.14 ERw4U9RM70uqOejxuU9GETtaS36S0> 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 f29sm10891032pff.169 - gsmtp
2018-04-30 12:17:15 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbvH534-5.7.14 Po6hfzTwq4hCMvLl_DdV9aGq22R-Ak0Vu_nq3jSd95TekrsnufIKHEH5N5XE4VDyIGA9lJ534-5.7.14 zc-jKgF2YAlfTXogT_7AeKcQBnpv8_5A7P8ZpDq6OXTmtlZA3qIYH1Kp8KgrbTrrOwXwRz534-5.7.14 Qj4-AoQL0mbHuJqW7Bo4wulTCBHBjOyTkMaImncgl9sBb7Iz4_z4fo_MgPJXiMAbmG6nyo534-5.7.14 ERw4U9RM70uqOejxuU9GETtaS36S0> 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 f29sm10891032pff.169 - gsmtp SMTP Error: Could not authenticate.
2018-04-30 12:17:15 CLIENT -> SERVER: QUIT
2018-04-30 12:17:15 SERVER -> CLIENT: 221 2.0.0 closing connection f29sm10891032pff.169 - gsmtp SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Код:
<?php
use PHPMailer\PHPMailer\PHPMailer;
require 'phpmail/vendor/autoload.php';
$mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPDebug = 2; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '@gmail.com'; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Set who the message is to be sent from
$mail->setFrom('curtis.boylan@gmail.com', 'First Last');
//Set an alternative reply-to address
//Set who the message is to be sent to
$mail->addAddress('curtis.boylan@gmail.com', 'Shehan');
//Set the subject line
$mail->Subject = 'Test Mail';
$mail->Body = 'This is Test Mail';
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>