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)