I have problem about sending mails with Google SMTP and latest version of PHPMailer. Here are a lot of questions, but the answers doesn't work for me.
I am using free hosting with free subdomain 000webhost
.
This is my standard PHP code for sending email from PHPMailer
docs:
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'GMAIL EMAIL ACCOUNT';
$mail->Password = 'MY PASSWORD FOR GMAIL EMAIL ACCOUNT';
$mail->SMTPSecure = 'tlc';
$mail->Port = 587;
$mail->SMTPDebug = 3;
$mail->setFrom('EMAIL ADDRESS', 'EXAMPLE');
$mail->addAddress('ADDRESS TO SEND', 'From contact form');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
and I get this error:
.... 2017-06-03 15:15:33 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials 203sm11822739ywk.62 - gsmtp 2017-06-03 15:15:33 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials 203sm11822739ywk.62 - gsmtp 2017-06-03 15:15:33 SMTP Error: Could not authenticate. .....
I see same error if I use ssl
with port 465
.
In my Gmail
email account 2-factory authentication is OFF
and Allow less secure apps
is ON
.
I really don't know what to do.
tlc
forSMTPSecure
. – Synchro