2

我正在使用以下代码在 codeigniter 中发送邮件

$this->load->library('email');
$this->email->set_mailtype('html');
$this->email->from('test@example.com', 'Your Name');
$this->email->to('test2@example.com'); 

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');  

$this->email->send();

echo $this->email->print_debugger();

在这里我得到错误

Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

但是如果邮件类型改为文本,即

$this->email->set_mailtype('text');

它工作正常。为什么会这样?

4

2 回答 2

1
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);

尝试这个。

于 2018-03-06T09:39:07.893 回答
0

需要一个 email.php 文件。

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

参考,这个网址:http ://www.ciboard.co.kr/user_guide/en/libraries/email.html

于 2017-05-21T09:49:52.750 回答