邮件错误邮件()没有连接

时间:2018-03-22 09:17:37

标签: php email smtp gmail phpmailer

<?php require 'PHPMailer_5.2.4/class.phpmailer.php';                    
$mail = new PHPMailer;
$mail->SMTPDebug=0;
$mail->isSMTP();                          // Set mailer to use SMTP
$mail->Host = 'gmail-smtp-in.l.google.com'; 
$mail->SMTPAuth = true;                  // Enable SMTP authentication
$mail->Username = 'demotp18@gmail.com';                   // SMTP username
$mail->Password = '****';             // * is just for not to show password
$mail->SMTPSecure = 'tls';         // Enable encryption, 'ssl' also accepted
$mail->Port = 587;          
$mail->setFrom('neelsoni.sn@gmail.com');
$mail->SMTPOptions = array(
'ssl' => array(
    'verify_peer' => false,
    'verify_peer_name' => false,
    'allow_self_signed' => true
) );

$mail->addAddress('demotp18@gmail.com');               // Name is optional
$mail->WordWrap = 50;                                 
$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}

echo 'Message has been sent';

 ?>

输出:无法发送消息.Mailer错误:以下发件人地址失败:neelsoni.sn@gmail.com:未连接称为Mail()

我的问题是关于PHPMAILER 代码中的问题是什么? 为什么我得到这个错误?我在gmail中打开安全性较低。 在HOST我试过smtp.gmail.com但是我看到了同样的错误,这就是为什么我找到这个主机类型。 我朋友的笔记本电脑中的相同代码正在工作,但另一位朋友正面临同样的错误。 请帮帮我!!!!!!!!!!

0 个答案:

没有答案
相关问题