SMTP could not authenticate

http://www.miladybaia.epizy.com

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="emailfrom@gmail.com";
$name=“name”;
$message=“Hello”;

$email = new PHPMailer(true);

$email->isSMTP();
$email->Port = "465";
$email->Host = "smtp.gmail.com";
$email->isHTML(true);
$email->SMTPSecure = "ssl";
$email->Mailer = "smtp";
$email->CharSet = "UTF-8";
$email->SMTPAuth = true;
$email->Username = "myemail@gmail.com";
$email->Password = "mypassword";
$email->SingleTo = true;

$email->AddAddress("destinationemail@gmail.com");
$email->AddReplyTo($from);
$email->SetFrom($from);
$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.
Thanks

2 Likes

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 myaccount.google.com
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.

Thanks

2 Likes

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.