Hello:
I am able to send emails using phpmailer and gmail when my website is hosted on my local WAMP stack. This means that I’ve configured my gmail account correctly and am using the correct phpmailer parameters to send emails.
When I moved my site to my infinityfree account, phpmailer is indicating that its failing authentication.
So I turned ON SMTP debuging to get a more verbose error. Here it is:
2019-05-24 05:19:04 SERVER -> CLIENT: 534-5.7.14 SMTP ERROR: Password command failed: Please log in via your web browser and then try again.534-5.7.14 Learn more at534 5.7.14
SMTP Error: Could not authenticate.
Here is the relevant PHP code that calls phpmailer:
$mail = new PHPMailer(true);
try {
$mail->isSMTP(); // Set mailer to use SMTP
$mail->SMTPDebug = 2;
//Server settings
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->Port = 587; // TCP port to connect to
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'xxxx'; // SMTP password
//Recipients
$mail->setFrom('[email protected]', 'Joselito');
$mail->addAddress($toEmail, 'Joe User'); // Add a recipient
// Content
$mail->Subject = $emailSubject;
$mail->Body = $emailContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Again, this all works in my local WAMP stack. Is there something more to be configured in order to get this working on infinityfree and the gmail SMTP smtp server?
Thanks in advance for your help.
/Joselito