I have an issue with PHPMailer. First i have integrated phpmailer and email are sent without any issues in localhost and live server. Since yesterday, i have an issues to send email in localhost but not in live server. The error i got when i send the email in localhost are
Email could not be sent to the recently approved member. ErrorSMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
This is the same code to send the emails both in live server and localhost.
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'someone@gmail.com'; // SMTP username
$mail->Password = $pw; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('someone@gmail.com', 'Reboot E-Magazine');
$mail->addAddress($email); // Add a recipient
$mail->Subject = 'Article Confirmation';
$mail->Body =
'Reboot Magazine
--------------------------------------------------------------------
Your article was not been approved due to certain reasons.
Please ensure the article are well-written and relevant to the topic.
--------------------------------------------------------------------
Sincerely,
Riyaz Ahmad
Admin of Reboot E-magazine';
if(!$mail->send())
{
$error = "Email could not be sent. Error". $mail->ErrorInfo;
}
else
{
$msg = "Email has been sent to notify the member";
}