SMTP Error: Could not authenticate using SMTP Gmail

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.

Please make sure you have Two Factor Authentication enabled on your account and have created an App Specific Password and entered it here. Getting SMTP to work without 2FA is finicky right now, and impossible soon, so setting up 2FA is recommended.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.