脚本宝典收集整理的这篇文章主要介绍了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中给出的示例时,还会出现另一个错误
在任何情况下,错误消息都非常清楚.主机未响应您的连接尝试.原因可能是服务器和PHP中的配置错误,防火墙问题,路由问题,DNS问题等.
以上是脚本宝典为你收集整理的PHPMailer无法连接到SMTP主机全部内容,希望文章能够帮你解决PHPMailer无法连接到SMTP主机所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。