Php 问题在localhost中发送电子邮件,但不在liveserver中发送

Php 问题在localhost中发送电子邮件,但不在liveserver中发送,php,phpmailer,Php,Phpmailer,我和PHPMailer有问题。 首先,我集成了phpmailer和电子邮件,在localhost和liveserver中发送时没有任何问题。从昨天开始,我在localhost中发送电子邮件时遇到了问题,但在live server中没有。我在localhost中发送电子邮件时遇到的错误是 无法向最近批准的成员发送电子邮件。错误SMTP连接失败 这与在live server和localhost中发送电子邮件的代码相同 $mail = new PHPMailer; $mail->isSMTP()

我和PHPMailer有问题。 首先,我集成了phpmailer和电子邮件,在localhost和liveserver中发送时没有任何问题。从昨天开始,我在localhost中发送电子邮件时遇到了问题,但在live server中没有。我在localhost中发送电子邮件时遇到的错误是

无法向最近批准的成员发送电子邮件。错误SMTP连接失败

这与在live server和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";
}

我相信这里已经回答了:

评论

$mail->isSMTP


通常可以解决此问题。

您是否阅读了链接到的疑难解答文章?它提供了一些很好的建议,甚至可以检查您的代码是否有明显的欺诈行为。现在可以很好地使用localhost了。但在live server中评论该部分有什么问题吗?不用担心。你不应该对此有任何问题。我刚刚发现电子邮件不会发送给特定的用户。我需要更改端口号还是tls加密?谢谢,顺便说一句,我已经取消了smtp部分的注释,并将端口号更改为587,它可以正常工作。。谢谢你的帮助