PHPMailer无法连接到SMTP主机

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHPMailer无法连接到SMTP主机脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
得到以下错误

这是我的配置文件设置,因为我遵循了这个PHPMailer tutorial

// Configuration settings for My SITe

// Email Settings
$site['From_name'] = 'Manish DekavaDIYa'; // from email name
$site['from_email'] = 'manish@<;my-domain>.COM'; // from email address

// Just in case we need to relay to a different server,// PRovide an option to use external mail server.
$site['smtp_mode'] = 'enabled'; // enabled or disabled
$site['smtp_host'] = "smtp.<my-domain>.com";
$site['smtp_port'] = 587;
$site['smtp_username'] = "manish@<my-domain>.com";
$site['smtp_password']="<password>";

并使用了mailer类和教程中提到的扩展类如下:

/*****sendmail.PHP****/

// Grab our config settings
require_once($_SERVER['DOCUMENT_ROOT'].'/config.PHP');

// Grab the FreakMailer class
//echo $_SERVER['DOCUMENT_ROOT'];
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/MailClass.inc');

// instantiate the class
$mailer = new FreakMailer();

// Set the subject
$mailer->Subject = 'This is a test';
 $mailer->SMTPDebug = 1;
// Body
$mailer->Body = 'This is a test of my mail system!';

// Add an address to send to.
$mailer->AddAddress('manish.dekavadiya@gmail.com','Manish Dekavadiya');

if(!$mailer->Send())
{
    echo 'There was a problem sending this mail!';
}
else
{
    echo 'Mail sent!';
}
$mailer->ClearAddresses();
$mailer->ClearAttachments();

当我尝试在PHPmailer docs @ examples / test_smtp_gmail_basic.PHP中给出的示例时,还会出现另一个错误

所以必须有设置或配置错误.没有代码错误.

是否设置了SMTP?如果是这样,它被配置为在端口587上收听smtp..com?如果服务器没有自己设置,那么他们收听mail..com的情况并不少见.此外,尝试连接到端口25以查看是否可以将其配置为侦听认的smtp端口.

在任何情况下,错误消息都非常清楚.主机未响应您的连接尝试.原因可能是服务器和PHP中的配置错误,火墙问题,路由问题,DNS问题等.

脚本宝典总结

以上是脚本宝典为你收集整理的PHPMailer无法连接到SMTP主机全部内容,希望文章能够帮你解决PHPMailer无法连接到SMTP主机所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。