fsockopen():php_network_getaddresses:getaddrinfo失败:名称或服务未知
Posted
技术标签:
【中文标题】fsockopen():php_network_getaddresses:getaddrinfo失败:名称或服务未知【英文标题】:fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known 【发布时间】:2017-02-21 11:02:09 【问题描述】:我无法将表单内容发送到电子邮件。我收到以下错误:
: Warning
Message: fsockopen(): php_network_getaddresses: getaddrinfo failed:Name or service not known
Filename: libraries/Email.php
Line Number: 1986
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.123mailsetup.com:25 (php_network_getaddresses: getaddrinfo failed: Name or service not known)
Filename: libraries/Email.php
Line Number: 1986
我的线 1986 是
$this->smtp_timeout);
我的控制器中的部分代码
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.xxxx.com',
'smtp_port' => 465,
'smtp_user' => 'xxxxx@xxx.com',
'smtp_pass' => 'xxxxxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->from('xxxxx@xxx.com', 'Mailsetup');
$this->email->to($email);
$this->email->subject('Domain transfer');
$this->email->message( '<html><body>Domain to be transfered '.$domain.' <br> Domain owner '.$name.' , <br> email '.$email.'
</body></html>' );
$this->email->send();
【问题讨论】:
如果主机名无法通过 DNS 解析,您可以使用 IP。请注意,尝试 ping smtp.123mailsetup.com 显示它无法解析,但 123mailsetup.com 确实解析为 77.235.54.121 验证电子邮件服务器的名称 谢谢大佬..这是问题..设法解决了 【参考方案1】:使用 PHP Mailer See Here
$mail = new PHPMailer(true);
$auth = true;
if ($auth)
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.xxxx.com";
$mail->Port = 465;
$mail->Username = "username@host.com";
$mail->Password = "xxxxxxxxxxxx";
$mail->AddAddress("xxxxxxxx@xxxxxx.com");
$mail->SetFrom("JohnDeo@xxx.com", "John Deo");
$mail->isHTML(true);
$mail->Subject = "Test Email";
$mail->Body = "Hello World";
try
$mail->Send();
return true;
catch(Exception $e)
echo $mail->ErrorInfo;
【讨论】:
以上是关于fsockopen():php_network_getaddresses:getaddrinfo失败:名称或服务未知的主要内容,如果未能解决你的问题,请参考以下文章