加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHPMailer中的SMTP connect()失败错误

发布时间:2020-12-13 22:34:59 所属栏目:PHP教程 来源:网络整理
导读:我是 PHP的新手,我想用 PHP发送邮件.我有一个联系我们表格,我会接受与我联系的人的电子邮件,因此邮件将发送给我.我正在使用 https://github.com/PHPMailer/PHPMailer/tree/master以上的PHPMailer库,以下是我正在使用的代码片段. ?phprequire("class.phpmaile
我是 PHP的新手,我想用 PHP发送邮件.我有一个联系我们表格,我会接受与我联系的人的电子邮件,因此邮件将发送给我.我正在使用 https://github.com/PHPMailer/PHPMailer/tree/master以上的PHPMailer库,以下是我正在使用的代码片段.
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();  

$mail->SMTPSecure = 'tls';

$mail->Host     = "resolver1.opendns.com"; // this SMTP server of my machine
//$mail->Host     = "208.67.222.222";//ip ; which one to use the resolver1.opendns.com or 208.67.222.222 ???

$mail->From     = "xyz@gamil.com;//email id of the person 

$mail->AddAddress("datta.dhonde@coreathena.com");//my email id

$mail->Subject  = "First PHPMailer Message";
$mail->Body     = "Hi! nn This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;

if(!$mail->Send()) 
{
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
}  
else 
{
  echo 'Message has been sent.';
}
?>

我收到错误“消息未发送.Mailer错误:SMTP连接()失败.”
我没有得到什么问题..?
$mail-> Host =“”;请评论这是什么意思?

添加$mail-> SMTPDebug = 1;并尝试调试问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读