PHPMailer 中的 SMTP 连接()失败错误

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

问题描述

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

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! 

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

我收到错误消息未发送.邮件程序错误:SMTP 连接()失败."我没有得到什么问题..?$邮件->主机=";请评论这代表什么?

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??

推荐答案

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

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

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)