调用Mail()而没有连接Mailed Error

时间:2017-08-22 03:28:10

标签: php email

嘿,我正致力于向用户发送邮件。我使用下面的代码它在几天前工作正常但今天当我打开并测试我的代码时它开始出错。请解决我的问题。

include "PHPMailer_5.2.4/class.phpmailer.php";
$mail = new PHPMailer();
$mail -> IsSMTP(); 
$mail -> SMTPDebug = 1; 
$mail -> SMTPAuth = true; 
$mail -> SMTPSecure = 'ssl'; 
$mail -> Host = "smtp.gmail.com";
$mail -> Port = 465; 
$mail -> IsHTML(true);
$mail -> Username = "nida.office123@gmail.com";
$mail -> Password = "*************";
$mail -> AddAddress($to,$nameM );
$mail -> Subject = "Payment Request";
$mail -> Body    = "<b>A payment request has been made. Please visit your panel and accept or disapprove the request.Visit the link below to perform the action. <center><a href=\"http://localhost/internshippro/login.php\">Login to continue</a></center></b>";
$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = 'index.php';
$crlf = "\n";
$hdrs = array(
    'email' => 'example@gmail.com',
    'Subject' => 'Test subject message',
    'comment' => 'Test comment',
);
if ($mail -> send($hdrs))
//if (mail($subject,$message, $headers))
{
    echo "<script> alert('Thank you for contacting us!');window.location = '';</script>";
} else {
    echo "Mailed Error: " . $mail -> ErrorInfo;
}

出现的错误是

  

SMTP - &gt;错误:无法连接到服务器:(0)

     

以下发件人地址失败:root @ localhost:不带

调用Mail()      

连接邮寄错误

0 个答案:

没有答案