SMTP could not authenticate

SMTP Error: Could not authenticate

I’m trying to set up a small contact form, and I’ve been having difficulties in sending emails, the code in question works correctly on the local server (wamp server), since I appreciate it

$from="[email protected]";

$email = new PHPMailer(true);

$email->Port = "465";
$email->Host = "";
$email->SMTPSecure = "ssl";
$email->Mailer = "smtp";
$email->CharSet = "UTF-8";
$email->SMTPAuth = true;
$email->Username = "[email protected]";
$email->Password = "mypassword";
$email->SingleTo = true;

$email->AddAddress("[email protected]");
$email->Subject = "Test";
$email->Body = $message." ".$name;


You do have those setup correctly right? For your password, you need to turn on “Allow Less Secure Apps” in your Google Account, and it is recommended you turn on 2FA (two-factor authorization) and generate an App Password instead of using your real Google Account password.


yes I already enabled “Allow less secure apps” and 2FA (two-factor permission)

But I need help, how can I generate an app password instead of using your real Google account password.
to infintyfree

To get a Google App Password:
Go to
Select “Security”
Select “App Passwords”
Select “Mail” and “Custom Name” from the dropdowns
Copy the provided password into your application. Note that once you close the window with the password, you will not be able to view the password again, you will have to generate a new one.



muito obrigado, consegui fazer o envio…obrigado de verdade

Your welcome! Glad you got it working.

1 Like

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