程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> CodeIgniter 發送郵件(smtp)

CodeIgniter 發送郵件(smtp)

編輯:關於PHP編程

              $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...';
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved