0

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)

Martin AJ
  • 6,261
  • 8
  • 53
  • 111
  • I can't even get a connection to `smtp.zoho.com` it appears to be offline – IsThisJavascript Aug 10 '18 at 08:53
  • @IsThisJavascript Oh sorry it was a typo .. edited .. – Martin AJ Aug 10 '18 at 08:55
  • If you manually login to the GMAIL email, is it saying stuff about suspicious login attempt? You may have to enable `Allow less secure apps` however this compromises your gmail security – IsThisJavascript Aug 10 '18 at 08:59
  • Set `$mail->SMTPDebug = 2` so you can see more of what google is saying, though it does already provide guidance in the error message you've got there when it says "Please log in via your web browser and then try again". Following the link to the troubleshooting guide would also be a *very* good idea since it tells you exactly how to deal with this problem, as do many other duplicates of this question on here. – Synchro Aug 10 '18 at 09:20
  • 1
    Possible duplicate of [Gmail SMTP debug: error "please log in via your web browser"](https://stackoverflow.com/questions/20337040/gmail-smtp-debug-error-please-log-in-via-your-web-browser) – Synchro Aug 10 '18 at 09:20

0 Answers0