Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

php - fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known

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

My line 1986 is

$this->smtp_timeout);

Part of the code in my controller

$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();
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...