SMTP 停止发送邮件 [英] SMTP stopped sending mails

查看:245
本文介绍了SMTP 停止发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站的各个页面上为 localhost XAMPP 运行了一个邮件传递脚本.直到昨晚它都工作正常,当我今天再次开始时,任何具有 phpmailer 脚本的页面都将错误显示为

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.

我没有对本地服务器配置和我的 GMAIL 凭据进行任何更改,但无法确定 SMTP 设置可能出了什么问题,因此出现此错误.我已经为此设置整齐地完成了所有设置,正如我所说,直到昨晚它都运行良好.

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.

推荐答案

PHPMailer 6.0.2

PHPMailer 6.0.2

下载:https://github.com/PHPMailer/PHPMailer/archive/master.zip

并使用代码

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

并插入代码:

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

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

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

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

这篇关于SMTP 停止发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆