我正在研究php框架codeigniter,电子邮件不是在localhost上发送我也从我用来发送邮件的反病毒中删除了端口465并且还关闭了反病毒它给出了错误 “fsockopen():SSL操作失败,代码为1”, fsockopen():无法启用加密
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '*******@gmail.com'; // change it to yours
$config['smtp_pass'] = '******'; // change it to yours
$config['charset' ] = 'iso-8859-1';
$config['newline' ] = "\r\n";
$config['mailtype' ] = 'text';
$config['validation' ] = TRUE;
$this->load->library('email',$config);
$this->email->from('*********@gmail.com');
$this->email->to('********@gmail.com');
$this->email->subject('Confirmation Email');
$this->email->message('Thank you');
if ($this->email->send())
{
echo "send successfully";
}
else
{
show_error($this->email->print_debugger());
}
这是我所做的代码,你可以解决这个问题吗?
答案 0 :(得分:0)
试试这个
使用ssl://smtp.gmail.com
。
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => '*************@gmail.com', // change it to yours
'smtp_pass' => '******', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('***@gmail.com'); // change it to yours
$this->email->to('***@gmail.com');// change it to yours
$this->email->subject('Confirmation Email');
$this->email->message('Thank you');
if($this->email->send())
{
/* echo 'Email sent.';*/
echo "send successfully";
}
else
{
show_error($this->email->print_debugger());
}
仍面临同样的问题,请尝试此链接GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP