PHPMailer中的SMTP connect()失败错误 [英] SMTP connect() failed error in PHPMailer

查看:127
本文介绍了PHPMailer中的SMTP connect()失败错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全是PHP的新手,我想用PHP发送邮件。我有一个联系我们的表格,将接受电子邮件是与我联系的人,因此邮件将发送给我。我正在使用 https://github.com/PHPMailer/PHPMailer/tree/master和以下是我使用的代码片段。

 <?php 
require(class.phpmailer .PHP);
$ mail = new PHPMailer();
$ mail-> IsSMTP();

$ mail-> SMTPSecure ='tls';

$ mail-> Host =resolver1.opendns.com; //我的机器的SMTP服务器
// $ mail-> Host =208.67.222.222; // ip;哪一个使用resolver1.opendns.com或208.67.222.222 ???

$ mail-> From =xyz@gamil.com; //该人的电子邮件ID

$ mail-> AddAddress(datta.dhonde@coreathena .com); //我的电子邮件ID

$ mail-> Subject =第一个PHPMailer消息;
$ mail-> Body =嗨! \\\
\\\
这是我通过PHPMailer发送的第一封电子邮件。;
$ mail-> WordWrap = 50;

if(!$ mail-> Send )
{
echo'消息未发送';
echo'Mailer错误:'。$ mail-> ErrorInfo;
}
else
{
echo'已发送消息';
}
?&$

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

解决方案

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


I am completely new to PHP and I want to send a mail using PHP. I have a Contact Us form whcih will accept email is of the person contacting me and therefore the mail will be sent to me. I am using PHPMailer library from https://github.com/PHPMailer/PHPMailer/tree/master and following is the code snippet I am using.

<?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! \n\n 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.';
}
?> 

I am getting the error " Message was not sent.Mailer error: SMTP connect() failed." I am not getting what is the problem..? $mail->Host = ""; please comment on what this stands for??

解决方案

Add $mail->SMTPDebug = 1; and try to debug the problem.

这篇关于PHPMailer中的SMTP connect()失败错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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