我正在使用以下代码在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');
它运作正常。为什么会这样?
答案 0 :(得分:1)
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
试试这个。
答案 1 :(得分:0)
需要email.php文件。
{
"asin": "0000031852",
"title": "Girls Ballet Tutu Zebra Hot Pink",
"price": 3.17,
"imUrl": "http://ecx.images-amazon.com/images/I/51fAmVkTbyL._SY300_.jpg",
"related":
{
"also_bought": ["B00JHONN1S", "B002BZX8Z6"],
"also_viewed": ["B002BZX8Z6", "B00JHONN1S", "B008F0SU0Y", "B00D23MC6W", "bought_together": ["B002BZX8Z6"]
},
"salesRank": {"Toys & Games": 211836},
"brand": "Coxlures",
"categories": [["Sports & Outdoors", "Other Sports", "Dance"]]
}
{
...
}
参考,此网址:http://www.ciboard.co.kr/user_guide/en/libraries/email.html