本文介绍了fsockopen():php_network_getaddresses:getaddrinfo失败:名称或服务未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法将表单内容发送到电子邮件.我收到以下错误:
I am failing to send form contents to email. I am getting the following error:
: 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' => '[email protected]',
'smtp_pass' => 'xxxxxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->from('[email protected]', '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();
推荐答案
使用PHP Mailer 在此处查看
Use 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 = "[email protected]";
$mail->Password = "xxxxxxxxxxxx";
}
$mail->AddAddress("[email protected]");
$mail->SetFrom("[email protected]", "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失败:名称或服务未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!