【发布时间】:2016-11-02 09:29:03
【问题描述】:
我在控制器 codeigniter 框架中有如下代码:
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
$this->load->library('email');
$this->email->from('example@yahoo.com', 'example');
$this->email->to('example@gmail.com','example');
$this->email->subject('my Subject');
$this->email->message('my Message');
if ($this->email->send())
echo "Mail Sent!";
else
echo "There is error in sending mail!";
}
}
此代码正确发送电子邮件。但是当我配置电子邮件类设置时,此代码不起作用并且不发送电子邮件。例如跟随代码不会发送电子邮件:
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
$this->load->library('email');
$this->email->from('example@yahoo.com', 'example');
$this->email->to('example@gmail.com','example');
$this->email->subject('my Subject');
$this->email->message('my Message');
$config['protocol'] = 'sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
if ($this->email->send())
echo "Mail Sent!";
else
echo "There is error in sending mail!";
}
}
请告诉我问题出在哪里。 谢谢。
【问题讨论】:
-
您是否尝试使用
SMTP协议发送邮件?
标签: codeigniter email send