$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' =>'abc@gmail.com',
'smtp_pass' => 'abc',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from($email,$name);
$this->email->to('abc@gmail.com');
$this->email->subject('ENQUERY');
$this->email->message($string);
$this->email->send();
此代码无法在godaddy服务器中运行。 错误: 严重性:警告
消息:fsockopen():无法连接到ssl://smtp.googlemail.com:465(拒绝连接)
答案 0 :(得分:0)
您的SSl端口可能会在godaddy共享主机中关闭。请查看以下代码
$fp = fsockopen("smtp.gmail.com", 465, &$errno, &$errstr, 10);
if (!$fp)
echo "smtp.gmail.com 465 is not working - $errstr ($errno)";
else
echo "smtp.gmail.com 465 is working";