//批量提交发送阿亮
public function WageMaildoSends($data)
ini_set('memory_limit', '3072M'); // 临时设置最大内存占用为3G
set_time_limit(0); // 设置脚本最大执行时间 为0 永不过期
$where['state'] = '0';
$table = 'hr_email_al';
$this->load->model('select');
$query = $this->select->getDataAll($where, $table);
if (count($query)<1){
echo json_encode(array('code' => 300, 'message' => '发送失败;原因:没有需要要发送的数据'));
return;
//邮件配置
$user['user'] = 'fundservice@zhizin-inv.com'; //发送人
$user['pass'] = 'B5QzZsBQC8PmHPqn';//授权码
$title = '转托管通知'; //邮件标题
$cc = ''; //抄送人
$success = 0; //发送成功数量
$fail = 0; //发送成功数量
foreach ($query as $row) {
if ($row['email'] !== '') {
$thml = '<div style="width: 100%;height: auto;font-size: 14pt;font-family:华文仿宋;text-indent:25pt">
<p style="text-indent:0pt">尊敬的投资者:</p>
<p> 雄关漫道真如铁,而今迈步从头越,感谢贵司美好相伴。</p>
<p> 2022年1月取得中国证券监</p>
<p> 贵司在基金开立账户中的产品份额将转托管至</p>
<p> 如有疑问,请联系您的客户经理。</p>
<p style="text-align: right;line-height:80pt">北京xxx有限公司</p>
</div>';
$to = $row['email']; //收件人
$isSend = $this->configMail_al($user, $thml, $title, $to, $cc);
if ($isSend) {
$this->db->where('id', $row['id']);
$this->db->update($table, array('state' => 1));
$success++;
} else {
$this->db->where('id', $row['id']);
$this->db->update($table, array('state' => 2));
$fail++;
$message = '发送成功数量' . $success . ';发送失败数量' . $fail;
$code = $success > 0 ? 200 : 300;
return json_encode(array('code' => $code, 'message' => $message));
//邮箱配置阿亮
public function configMail_al( $user,$thml, $title, $to, $cc ) {
header('Content-Type: application/octet-stream');
$this->load->library( 'email' ); //加载CI的email类
//以下设置Email参数
$config[ 'protocol' ] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.qiye.163.com';
$config[ 'smtp_user' ] = $user[ 'user' ];
$config[ 'smtp_pass' ] = $user[ 'pass' ];
$config[ 'smtp_port' ] = '465';
$config[ 'charset' ] = 'utf-8';
$config[ 'wordwrap' ] = TRUE;
$config[ 'mailtype' ] = 'html';
$config['newline'] = "\r\n"; // 设置换行符
$this->email->initialize( $config );
//以下设置Email内容
$this->email->from( $user[ 'user' ]);
$this->email->to( $to );
$this->email->cc( $cc );
$this->email->subject( $title );
$this->email->message( $thml );
$this->email->attach('/software/cf.xinfu.com/wwwroot/public/zhuantuoguantongzhi.pdf');