SMTP stopped sending mails

﹥>﹥吖頭↗ 提交于 2019-12-13 20:33:48

问题


I have a mail delivering script running on various pages in my website for localhost XAMPP. It was working fine till last evening and as I started today again any page having phpmailer script gives error as

SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed.

I haven't changed anything into the local server configuration and my GMAIL credentials but unable to figure out possibly what has gone wrong into the SMTP settings so that this error is coming up. I have done all my settings neatly for this setup and as I said it was working well till last evening.

<?php
require('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$subject = "Test Mail using PHP mailer";
$content = "<b>This is a test mail using PHP mailer class.</b>";

$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "ssl";
$mail->Debugoutput = 'html';
$mail->Port     = 465; 
$mail->Username = "emailsender@email.com";
$mail->Password = "*******";
$mail->Host     = "ssl://smtp.gmail.com";
$mail->Mailer   = "smtp";
$mail->SetFrom("emailsender@email.com", "");
$mail->AddAddress("emailreceiver@email.com");
$mail->Subject = $subject;
$mail->WordWrap   = 80;
$mail->MsgHTML($content);
$mail->IsHTML(true);

if(!$mail->Send()) 
    echo "Problem on sending mail";
else 
echo "Mail sent";
?>

I am just unable to find out any possible reason for this . Any help or advice will be appreciated.


回答1:


PHPMailer 6.0.2

Download: https://github.com/PHPMailer/PHPMailer/archive/master.zip

and use the code

https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps

and insert code:

$mail->SMTPOptions = array ( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));

========================================================================



来源:https://stackoverflow.com/questions/47646977/smtp-stopped-sending-mails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!