emailAction.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * 要用计划任务运行的,建议半小时运行一次
  4. * php task.php email
  5. */
  6. class emailClassAction extends runtAction
  7. {
  8. /**
  9. * 自动接收邮件,必须用cli运行的哦
  10. */
  11. public function defaultAction()
  12. {
  13. $rows = $this->db->getall("select b.`id`,b.`name`,b.`email` from `[Q]option` a left join `[Q]admin` b on a.`optid`=b.`id` where b.`status`=1 and a.`num` like 'email_recexin_%' and ifnull(a.`value`,'')<>''");
  14. $cg = $sb = 0;
  15. $tzid = '';
  16. $estr = '';
  17. foreach($rows as $k=>$rs){
  18. if(isempt($rs['email']))continue; //没设置邮箱
  19. $uid = $rs['id'];
  20. $this->rock->adminid = $uid;
  21. $this->rock->adminname = '系统';
  22. $barr = m('emailm')->receemail($uid);
  23. if(is_array($barr)){
  24. $cg+=$barr['count'];
  25. if($barr['count']>0)$tzid.=','.$uid.'';
  26. }else{
  27. $estr.=''.$uid.'.'.$barr.';';
  28. $sb++;
  29. }
  30. }
  31. if($estr!='')m('log')->addlogs('收邮件', $estr, 2);
  32. //发通知
  33. if($tzid!=''){
  34. $flow = m('flow')->initflow('emailm');
  35. $flow->push(substr($tzid,1),'','有未读的新邮件,现在是'.$this->rock->now.',请进入邮件应用查看详情。','新邮件提醒', 0, array(
  36. 'wxurl' => $flow->getwxurl()
  37. ));
  38. }
  39. return 'success('.$cg.'),fail('.$sb.')';
  40. }
  41. /**
  42. * curl异步发邮件
  43. * php task.php email,anaysend -id=1 -stype=1
  44. */
  45. public function anaysendAction()
  46. {
  47. $id = (int)$this->getparams('id','0');
  48. $stype = (int)$this->getparams('stype','0');
  49. $msg = m('email')->sendemailcont($id,$stype);
  50. if($msg!='ok')m('log')->addlogs('邮件', $msg , 2);
  51. return $msg;
  52. }
  53. }
粤ICP备19079148号