我想从Codeigniter发送电子邮件,我的代码就像这样
function sendMail(){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'myemail@gmail.com',
'smtp_pass' => 'mypassword',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = 'test message';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('myemail@gmail.com');
$this->email->to('somebody@gmail.com');
$this->email->subject('Test Message');
$this->email->message($message);
if($this->email->send()){
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
我编辑了php.ini并启用了opensll。但是当我尝试发送电子邮件时,我的代码导致空白页面,没有成功消息或错误消息出现。我不知道该怎么办,有什么线索吗?
答案 0 :(得分:0)
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'temp@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
许多是smtp主机的错误试试这个
答案 1 :(得分:0)
使用:
$this->email->send()
$this->email->print_debugger()
而不是:
if($this->email->send()){
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
调试