I was facing a “SMTP Error: Could not authenticate.” when sending out an email via smtp.gmail.com.
I am using PHPMailer and SMTP Gmail, below are the settings: -
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '<username>@gmail.com';
$mail->Password = '<gmail password>';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587;
Gmail Username & Password are correct.
Kindly advise.
Thank you.