Hello, I am trying to host my website that has a signup Gmail verification using PHP mailer. My code is working fine on localhost but when I host it here my code does not work anymore.
Here is my code:
require ‘php/PHPMailer.php’;
require ‘php/SMTP.php’;
require ‘php/Exception.php’;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
$mail = new PHPMailer;
$mail->Host = “smtp.gmail.com ”;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = ‘tls’;
$mail->isHTML(true);
$mail->Username = “[email protected] ”;
$mail->Password = ‘mypass’;
$mail->setFrom(‘[email protected] ’,‘AraLink’);
$mail->addAddress($email);
$mail->Subject=‘Email Verification Code’;
$mail->Body=“Your verification code is $code ”;
Thank you!
Update I added $mail->isSMTP(); to my code and it gives me SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub ;
The problem can likely be solved by completing the steps below.
Do this:
Turn on “Less Secure Apps” in your Google Account settings
Turn on 2Fa (Two Factor Authorization) on your account
Generate an app password (Under the Privacy tab in your Google Account Settings) and use that instead of your normal password
3 Likes
Admin
August 7, 2021, 1:24pm
5
Please see this article from two days ago, the situation seems exactly the same:
Try this.
Ensure that “Less Secure Apps” is enabled in your Google Account Settings.
Turn on 2Fa (Two Factor Authorization) on your Google account
Generate an App Password for your account (It’s under “Privacy”) and use that instead of your real password.
Apply the changes and upload to the server
Clear your cache and cookies and let me know if it works.
2 Likes
Thank you! Its now working
1 Like
system
Closed
August 14, 2021, 1:47pm
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.