`
TRAMP_ZZY
  • 浏览: 133081 次
社区版块
存档分类
最新评论

CodeIgniter 发送邮件(smtp)

阅读更多
$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'] = 'zhangzhaoyu0624@163.com';
$config['smtp_pass'] = 'zhangzhaoyu';

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

$this->email->from('zhangzhaoyu0624@163.com', 'zhangzhaoyu');
$this->email->to('245464918@qq.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...';
}


  


  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics