/**
*編碼爲utf-8
*
*/
<?php
class Sendmail extends Controller {
function Sendmail(){
parent::Controller();
}
function mail()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.qq.com',//服務器
'smtp_port' => '25',
'smtp_user' => '[email protected]',//from
'smtp_pass' => 'houryh3035',//password
'mailtype' => 'html',//郵件類型
'charset' => 'utf-8'//編碼
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$from_name = "華領網絡";//發件人名稱
$email_subject = "GPS上客戶登記:";//標題
$email_body = "士大夫論文242sdfl;sfl";//內容
//解決中文亂碼問題
$from_name = iconv('GB2312','UTF-8',$from_name);//編碼轉換,把gb2312轉換成utf-8
$email_subject = iconv('GB2312','UTF-8',$email_subject);
$email_body = iconv('GB2312','UTF-8',$email_body);
$this->email->from('[email protected]', $from_name);
$this->email->to('[email protected]');//to
$this->email->subject($email_subject);
$this->email->message($email_body);
if (!$this->email->send())
{
show_error($this->email->print_debugger());
return false;
}
else
{
return true;
}
}
}
?>
本文來自:http://hi.baidu.com/ssfnadn/blog/item/d25d5fc488d4f0af8226acb9.html
另外:
如果icnov 不能使用參考:
http://www.jb51.net/article/14530.htm
http://apps.hi.baidu.com/share/detail/1797448