郵箱一般接受gb2312、gbk、big5、ansi編碼,你可以將utf-8編碼轉換成gb2312
function sendmail(){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'mail.cmcc.cn',
'smtp_port' => 25,
'smtp_user' => 'lichao',
'smtp_pass' => '123',
'charset' => 'gb2312',
'mailtype' => 'html',
);
//SSL的方法
// $config_ssl = Array(
// 'protocol' => 'smtp',
// 'smtp_host' => 'ssl://smtp.gmail.com',
// 'smtp_port' => '465',
// 'smtp_user' => '[email protected]',
// 'smtp_pass' => '123',
// 'mailtype' => 'html',
// );
$this->load->library('email', $config);
$this->email->set_newline("rn");
$from_name = "小李";//發件人名稱
$email_subject ="調單";
$email_msg="<br>你好!請注意查收!";
//解決亂碼問題
$from_name = iconv('UTF-8','GB2312',$from_name);
$email_subject = iconv('UTF-8','GB2312',$email_subject);
$email_msg = iconv('UTF-8','GB2312',$email_msg);
//封裝發送信息
$this->email->from('[email protected]',$from_name);
$this->email->to('[email protected]');
$this->email->subject($email_subject);
$this->email->message($email_msg);
$this->email->attach("attachments/2009/01/1.xls");//附件
//發送
if (!$this->email->send())
{
show_error($this->email->print_debugger());
return false;
}
else
{
echo"發送成功!";
return true;
}
}