发邮件代码详情
private function _send_mail($data) {
//附件一,名称参数编码转换
if(!empty($data['resume_name'])){
$file_name = iconv('UTF-8','GB2312',$data['file_name']);
}
//附件二,名称参数编码转换
if(!empty($data['resume_name'])){
$resume_name = iconv('UTF-8','GB2312',$data['resume_name']);
}
//附件一URL
$file_url = $data['file_url'];
//附件二URL
$resume_url = $data['resume_url'];
//邮件主题
$email_theme =$data['email_theme'];
//邮件正文
$email_msg = $data['email_msg'];
//加载CI的email类
$this->load->library('email');
//以下设置Email参数
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.163.com';
$config['smtp_user'] = 'ban****277';//发件邮箱账号
$config['smtp_pass'] = '*********';//发件邮箱授权码
$config['smtp_port'] = '25';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
//以下设置Email内容
$this->email->from('ba****277@163.com','bangying');//发件人邮箱
$this->email->to('****@**.org');//收件人邮箱
if(!empty($file_url)){
$this->email->attach($file_url,'',$file_name);//添加附件一
}
if(!empty($resume_url)){
$this->email->attach($resume_url,'',$resume_name);//添加附件二
}
$this->email->subject($email_theme);//邮件主题
$this->email->message($email_msg);//邮件正文
//发送邮件
$this->email->send();
}
163授权码如何获取截图
image.png
image.png