配置:
$config['email_config']['protocol'] = 'smtp';
$config['email_config']['smtp_host'] = 'smtp.qq.com';
$config['email_config']['smtp_user'] = '***@qq.com';
$config['email_config']['smtp_pass'] = '***';//授权码,不是QQ密码,下面有介绍
$config['email_config']['smtp_port'] = 465;
$config['email_config']['smtp_crypto'] = 'ssl';
$config['email_config']['charset'] = 'utf-8';
$config['email_config']['wordwrap'] = TRUE;
$config['email_config']['mailtype'] = 'html';
$config['email_config']['crlf'] = "\r\n";
$config['email_config']['newline'] = "\r\n";//必须是双引号
使用:
$this->load->library('email');
$config = $this->config->item('email_config');
$this->email->initialize($config);
$this->email->from('***@qq.com', '***'); //发送方
$this->email->to(***); //接收方
$this->email->subject(***); //主题
$this->email->message(***); //邮件内容
$this->email->attach(***); //附件
$this->email->send(); //发送
smtp_pass:密码不能填QQ密码,要在QQ邮箱的设置->账户->服务里面开启IMAP/SMTP服务,填写生成的授权码。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。