首頁  >  文章  >  後端開發  >  CodeIgniter 发送邮件(smtp)_PHP教程

CodeIgniter 发送邮件(smtp)_PHP教程

WBOY
WBOY原創
2016-07-14 10:06:41839瀏覽

              $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'] = 'example0624@163.com';
$config['smtp_pass'] = 'password';

$this->email->initialize($config);

$this->email->from('example0624@163.com', 'example');
$this->email->to('tosombody@qq.com');
//设置抄送 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...';
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477911.htmlTechArticle$this-load-library(email); $config[protocol] = smtp; //发送给QQ用户,要显示中文用 iso-8859-1 $config[charset] = iso-8859-1; //发送给163用户,要显示中文用gb2...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn