$this->load->library('email');
$config['protocol'] = 'smtp';
//發送給QQ用戶,要顯示中文用 'iso-8859-1'
$config['charset'] = 'iso-8859-1';
//發送給163用戶,要顯示中文用'gb2312'
//$config['charset'] = 'gb2312';
$config['mailpath'] = 'news/index';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'password';
$this->email->initialize($config);
$this->email->from('[email protected]', 'example');
$this->email->to('[email protected]');
//設置抄送 www.2cto.com
//$this->email->cc();
//設置暗送
//$this->email->bcc();
$this->email->subject("The test of CodeIgniter's sending mail");
$this->email->message('你好,這是我的測試程序。通過CodeIgniter成功發送的郵件,請勿回復。');
//路徑需要使用絕對路徑
$this->email->attach('D:/QCallServer/htdocs/CI/public/images/google.jpg');
if ($this->email->send()) {
echo 'success...';
} else {
echo 'failed...';
}