我是codeigniter中的新手我想使用codeigniter電子郵件類發送電子郵件,但我是得到錯誤的fsockopen():無法連接到smtp.googlemail.com:465(連接超時)我試圖解決這個問題,但沒有運氣獲取錯誤fsockopen():無法連接到smtp.googlemail.com:465(連接超時),同時使用codeigniter電子郵件類發送電子郵件
public function signup()
{
$this->form_validation->set_rules('email','Email','required|valid_email|is_unique[fbadmin.email]');
$this->form_validation->set_error_delimiters("<p class='text-danger'>","</p>");
if($this->form_validation->run()==TRUE)
{
$data= $this->input->post();
unset($data['submit']);
//print_r($data);exit;
$this->load->model('Fbadminmodel');
if($this->Fbadminmodel->signup($data))
{
//$this->load->library('email');
$config = array(
'protocol' =>'smtp',
'smtp_host' =>'smtp.googlemail.com',
'smtp_port' =>'465',
'smtp_user' =>'[email protected]',
'smtp_pass' =>'password',
'mail_type' =>'html',
'charset' =>'utf-8'
);
//$this->email->initialize($config);
$this->load->library('email', $config);
$this->email->from('[email protected]','Anuj Kumar');
$this->email->to($data);
$this->email->message('www.haiviral.com');
$this->email->set_newline("\r\n");
if($this->email->send())
{
//$this->session->set_flashdata('feedback','Succefully Registred. Please verify your email');
echo "mail send";
}
else
{
show_error($this->email->print_debugger());
}
}
else
{
$this->load->view('fbadmin');
$this->session->set_flashdata('feedback','Registration Failed');
}
//$this->session->flashdata('flash','Email Sent');
$this->load->view('fbadmin');
}
else
{
echo validation_errors();
$this->load->view('fbadmin');
}
}
確保延長=在你的php.ini和 ' 'smtp_host'=>「啓用SSL php_openssl.dll:// smtp.googlemail.com'',通過您的文章作爲int value – webDev
php_openssl.dll已經打開 –
make''smtp_host'=>'ssl:// smtp.googlemail.com'',以int的形式傳遞你的帖子 – webDev