PHPMailer无法连接到SMTP主机 [英] PHPMailer could not connect to SMTP host

查看:78
本文介绍了PHPMailer无法连接到SMTP主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出现以下错误:

SMTP->错误:无法连接到服务器:php_network_getaddresses:getaddrinfo失败:此类主机未知. (0) SMTP错误:无法连接到SMTP主机.发送此邮件时出现问题!

SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: No such host is known. (0) SMTP Error: Could not connect to SMTP host. There was a problem sending this mail!

这是我的配置文件设置,因为我已经遵循此 PHPMailer教程

This is my config file setting as I have followed this 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类和扩展类,如下所示:

and used mailer class and an extended class as mentioned in tutorial as following:

/***** sendmail.php ****/

/*****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中给出的示例时,也遇到另一个错误

also getting another error when I tried an example given in phpmailer docs @ examples/test_smtp_gmail_basic.php

SMTP->错误:无法连接到服务器:php_network_getaddresses: getaddrinfo失败:没有这样的主机 众所周知. (0)SMTP错误:无法 连接到SMTP主机.有一个 发送此邮件时出现问题!

SMTP -> ERROR: Failed to connect toserver: php_network_getaddresses: getaddrinfo failed: No such host is known. (0) SMTP Error: Could not connect to SMTP host. There was a problem sending this mail!

因此必须存在设置或配置错误.不会有代码错误.

so there must be setting or configuration error. there can't be code error.

推荐答案

是否已在SMTP上设置?如果是,它是否配置为在端口587上侦听smtp..com?如果服务器不是您自己设置的,那么他们通常会改用mail..com收听.另外,尝试连接到端口25,以查看是否可以将其配置为侦听默认的smtp端口.

Is SMTP set up on ? And if so is it configured to listen to smtp..com on port 587? If the server is not set up by yourself it's not uncommon that they listen to mail..com instead. Also, try to connect to port 25 to see if it might be configured to listen to the default smtp port.

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

The error messages is in any case very clear. The host is not responding to your connection attempt. The reason could be missconfigurations in both the server and in PHP, firewall issues, routing issues, DNS issues etc.

这篇关于PHPMailer无法连接到SMTP主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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