Send_email1_adminAction.class.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * 邮件发送,普通发送
  4. */
  5. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  6. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  7. class Send_email1_adminAction extends Action{
  8. public function __construct(){
  9. parent::__construct();
  10. if(empty($_SESSION['mds_user'])){
  11. header("Location:/?a=index&m=admin_login");
  12. exit();
  13. }
  14. }
  15. public function index(){
  16. $admin = new AdvertAdminAction();
  17. $api_user = $_SESSION['API_USER'];
  18. $api_key = $_SESSION['API_KEY'];
  19. $from = $_SESSION['FROM'];
  20. $uid = $_SESSION['user_infos']['id'];
  21. $info = $_REQUEST['info'];
  22. $post_url = 'http://api.sendcloud.net/apiv2/mail/send';
  23. if($_POST){
  24. if(!empty($_POST['email_title']) && !empty($_POST['email_content'])){
  25. $subject = $_POST['email_title'];
  26. $content = $_POST['email_content'];
  27. $content = str_replace("\n","<br/>",$content);
  28. $replyto = $_SESSION['user_infos']['email'];//发件人邮箱地址
  29. $to = '';//收件人地址
  30. $customer_list = $admin->selesctCustomer("where uid='$uid'");
  31. foreach($customer_list as $list){
  32. $to .= $list['email'].';';
  33. }
  34. $to = trim($to,';');
  35. $params = array(
  36. 'apiUser' => $api_user,
  37. 'apiKey' => $api_key,
  38. 'to' => $to,
  39. 'from' => $from,
  40. 'subject' => $subject,
  41. 'html' => $content,
  42. 'replyto' => $replyto
  43. );
  44. $result = make_curl($post_url,$params);
  45. //插入 普通邮件发送日志表
  46. $params['uid'] = $uid;
  47. $params['message'] = $result['message'];
  48. $params['time'] = time();
  49. $insert_log = $admin->inserEmail1Log($params);
  50. $info = $result['message'];
  51. header("Location:/?a=send_email1_admin&m=index&info=$info");
  52. exit();
  53. }else{
  54. $info = "邮件标题、邮件内容为必填项,请填写完整!";
  55. }
  56. }
  57. $this->assign('info',$info);
  58. $this->display("index.html");
  59. }
  60. // class end
  61. }
  62. ?>