public function send()
 {
     $id = intval($_REQUEST['id']);
     $msg_item = M("DealMsgList")->getById($id);
     if ($msg_item) {
         if ($msg_item['send_type'] == 0) {
             //短信
             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
             $sms = new sms_sender();
             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
             $msg_item['result'] = $result['msg'];
             $msg_item['is_success'] = intval($result['status']);
             $msg_item['send_time'] = TIME_UTC;
             M("DealMsgList")->save($msg_item);
             if ($result['status']) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $result['msg'];
             }
         } else {
             //邮件
             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
             $mail = new mail_sender();
             $mail->AddAddress($msg_item['dest']);
             $mail->IsHTML($msg_item['is_html']);
             // 设置邮件格式为 HTML
             $mail->Subject = $msg_item['title'];
             // 标题
             $mail->Body = $msg_item['content'];
             // 内容
             $result = $mail->Send();
             $msg_item['result'] = $mail->ErrorInfo;
             $msg_item['is_success'] = intval($result);
             $msg_item['send_time'] = TIME_UTC;
             M("DealMsgList")->save($msg_item);
             if ($result) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $mail->ErrorInfo;
             }
         }
     } else {
         header("Content-Type:text/html; charset=utf-8");
         echo l("SEND_NOW") . l("FAILED");
     }
 }
Beispiel #2
0
 public function send_demo()
 {
     $test_mail = $_REQUEST['test_mail'];
     require_once APP_ROOT_PATH . "system/utils/es_mail.php";
     $mail = new mail_sender();
     $mail->AddAddress($test_mail);
     $mail->IsHTML(0);
     // 设置邮件格式为 HTML
     $mail->Subject = l("DEMO_MAIL");
     // 标题
     $mail->Body = l("DEMO_MAIL");
     // 内容
     if (!$mail->Send()) {
         $this->error(l("ERROR_INFO") . $mail->ErrorInfo, 1);
     } else {
         $this->success(l("SEND_SUCCESS"), 1);
     }
 }
Beispiel #3
0
 $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "promote_msg_list where id = " . $id);
 if ($msg_item) {
     //优先改变发送状态,不论有没有发送成功
     $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_send = 1,send_time='" . get_gmtime() . "' where id =" . intval($msg_item['id']));
     if ($msg_item['send_type'] == 0) {
         //短信
         require_once APP_ROOT_PATH . "system/utils/es_sms.php";
         $sms = new sms_sender();
         $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
         //发送结束,更新当前消息状态
         $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_success = " . intval($result['status']) . ",result='" . $result['msg'] . "' where id =" . intval($msg_item['id']));
     }
     if ($msg_item['send_type'] == 1) {
         //邮件
         require_once APP_ROOT_PATH . "system/utils/es_mail.php";
         $mail = new mail_sender();
         $mail->AddAddress($msg_item['dest']);
         $mail->IsHTML($msg_item['is_html']);
         // 设置邮件格式为 HTML
         $mail->Subject = $msg_item['title'];
         // 标题
         //发送推广邮件时加上退订的内容
         if ($msg_item['is_html']) {
             $msg_item['content'] .= "<br />" . sprintf(app_conf("UNSUBSCRIBE_MAIL_TIP"), app_conf("SHOP_TITLE"), "<a href='" . get_domain() . APP_ROOT . "/tuan.php?ctl=subscribe&act=unsubscribe&code=" . base64_encode($msg_item['dest']) . "'>" . $GLOBALS['lang']['CANCEN_EMAIL'] . "</a>");
         } else {
             $msg_item['content'] .= " \n " . sprintf(app_conf("UNSUBSCRIBE_MAIL_TIP"), app_conf("SHOP_TITLE"), $GLOBALS['lang']['CANCEN_EMAIL'] . get_domain() . APP_ROOT . "/tuan.php?ctl=subscribe&act=unsubscribe&code=" . base64_encode($msg_item['dest']));
         }
         $mail->Body = $msg_item['content'];
         // 内容
         $is_success = $mail->Send();
         $result = $mail->ErrorInfo;
Beispiel #4
0
 function init_mail()
 {
     if (defined('DISABLE_CRON')) {
         return;
     }
     $queue = getSetting('mail_queue');
     if (!$queue) {
         return;
     }
     $mail = DB::fetch_first("SELECT * FROM mail_queue LIMIT 0,1");
     if ($mail) {
         DB::query("DELETE FROM mail_queue WHERE id='{$mail[id]}'");
         $_mail = new mail_content();
         $_mail->address = $mail['to'];
         $_mail->subject = $mail['subject'];
         $_mail->message = $mail['content'];
         $sender = new mail_sender();
         $sender->sendMail($_mail);
     } else {
         saveSetting('mail_queue', 0);
     }
 }
Beispiel #5
0
         saveSetting('AFENABLED', 1);
     }
     showmessage('Advance fetures activated!', 'admin.php#setting', 1);
     break;
 case 'mail_test':
     if ($formhash != $_GET['formhash']) {
         showmessage('来源不可信,请重试', 'admin.php#setting');
     }
     $to = DB::result_first("SELECT email FROM member WHERE uid='{$uid}'");
     $subject = '[贴吧签到助手] 邮件单发测试';
     $content = "<p>此封邮件仅用于检测邮件系统是否正常工作。</p><p>此封邮件是由邮件系统直接发送的</p>";
     $mail = new mail_content();
     $mail->address = $to;
     $mail->subject = $subject;
     $mail->message = $content;
     $sender = new mail_sender();
     if ($sender->sendMail($mail)) {
         $subject = '[贴吧签到助手] 邮件群发测试';
         $content = "<p>此封邮件仅用于检测邮件队列是否正常工作。</p><p>此封邮件是从系统邮件队列中读取并发送的</p>";
         DB::insert('mail_queue', array('to' => $to, 'subject' => $subject, 'content' => $content));
         saveSetting('mail_queue', 1);
         showmessage('2 封邮件已经发送,请查收', 'admin.php#setting', 2);
     } else {
         showmessage('邮件发送失败,请检查设置后重试', 'admin.php#setting', 2);
     }
     break;
 case 'send_mail':
     if ($formhash != $_POST['formhash']) {
         showmessage('来源不可信,请重试', 'admin.php#setting');
     }
     $title = daddslashes($_POST['title']);
function send_sms_email($msg_item)
{
    $re = array('status' => 0, 'msg' => '');
    if ($msg_item['send_type'] == 0) {
        //短信
        require_once APP_ROOT_PATH . "system/utils/es_sms.php";
        $sms = new sms_sender();
        $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
        //发送结束,更新当前消息状态
        //$GLOBALS['db']->query("update ".DB_PREFIX."deal_msg_list set is_success = ".intval($result['status']).",result='".$result['msg']."',send_time='".TIME_UTC."' where id =".intval($msg_item['id']));
        $re['status'] = intval($result['status']);
        $re['msg'] = $result['msg'];
    }
    if ($msg_item['send_type'] == 1) {
        //邮件
        require_once APP_ROOT_PATH . "system/utils/es_mail.php";
        $mail = new mail_sender();
        $mail->AddAddress($msg_item['dest']);
        $mail->IsHTML($msg_item['is_html']);
        // 设置邮件格式为 HTML
        $mail->Subject = $msg_item['title'];
        // 标题
        $mail->Body = $msg_item['content'];
        // 内容
        $is_success = $mail->Send();
        $result = $mail->ErrorInfo;
        //发送结束,更新当前消息状态
        //$GLOBALS['db']->query("update ".DB_PREFIX."deal_msg_list set is_success = ".intval($is_success).",result='".$result."',send_time='".TIME_UTC."' where id =".intval($msg_item['id']));
        $re['status'] = intval($is_success);
        $re['msg'] = $result;
    }
    return $re;
}
 public function send()
 {
     $id = intval($_REQUEST['id']);
     $msg_item = M("PromoteMsgList")->getById($id);
     if ($msg_item) {
         if ($msg_item['send_type'] == 0) {
             //短信
             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
             $sms = new sms_sender();
             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
             $msg_item['result'] = $result['msg'];
             $msg_item['is_success'] = intval($result['status']);
             $msg_item['send_time'] = TIME_UTC;
             M("PromoteMsgList")->save($msg_item);
             if ($result['status']) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $result['msg'];
             }
         } else {
             //邮件
             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
             $mail = new mail_sender();
             $mail->AddAddress($msg_item['dest']);
             $mail->IsHTML($msg_item['is_html']);
             // 设置邮件格式为 HTML
             $mail->Subject = $msg_item['title'];
             // 标题
             if ($msg_item['is_html']) {
                 $mail_content = $msg_item['content'] . "<br />" . sprintf(app_conf("UNSUBSCRIBE_MAIL_TIP"), app_conf("SHOP_TITLE"), "<a href='" . SITE_DOMAIN . APP_ROOT . "/subscribe.php?act=unsubscribe&code=" . base64_encode($msg_item['dest']) . "'>" . $GLOBALS['lang']['CANCEN_EMAIL'] . "</a>");
             } else {
                 $mail_content = $msg_item['content'] . " \n " . sprintf(app_conf("UNSUBSCRIBE_MAIL_TIP"), app_conf("SHOP_TITLE"), $GLOBALS['lang']['CANCEN_EMAIL'] . SITE_DOMAIN . APP_ROOT . "/subscribe.php?act=unsubscribe&code=" . base64_encode($msg_item['dest']));
             }
             $mail->Body = $mail_content;
             // 内容
             $result = $mail->Send();
             $msg_item['result'] = $mail->ErrorInfo;
             $msg_item['is_success'] = intval($result);
             $msg_item['send_time'] = TIME_UTC;
             M("PromoteMsgList")->save($msg_item);
             if ($result) {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("SUCCESS");
             } else {
                 header("Content-Type:text/html; charset=utf-8");
                 echo l("SEND_NOW") . l("FAILED") . $mail->ErrorInfo;
             }
         }
     } else {
         header("Content-Type:text/html; charset=utf-8");
         echo l("SEND_NOW") . l("FAILED");
     }
 }
Beispiel #8
0
 public function promote_msg_list()
 {
     set_time_limit(0);
     //推广队列的群发
     $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 1 where name = 'PROMOTE_MSG_LOCK' and `value` = 0");
     $rs = $GLOBALS['db']->affected_rows();
     if ($rs) {
         $promote_msg = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "promote_msg where send_status <> 2 and send_time <= " . NOW_TIME . " order by id asc limit 1");
         if ($promote_msg) {
             $last_id = intval($GLOBALS['db']->getOne("select value from " . DB_PREFIX . "conf where name = 'PROMOTE_MSG_PAGE'"));
             //开始更新为发送中
             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg set send_status = 1 where id = " . intval($promote_msg['id']) . " and send_status <> 2");
             switch (intval($promote_msg['send_type'])) {
                 case 0:
                     //会员组
                     $group_id = intval($promote_msg['send_type_id']);
                     if ($promote_msg['type'] == 0) {
                         //短信
                         $sql = "select u.id,u.mobile from " . DB_PREFIX . "user as u where u.mobile <> '' ";
                         if ($group_id > 0) {
                             $sql .= " and u.group_id = " . $group_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['mobile'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     if ($promote_msg['type'] == 1) {
                         //邮件
                         $sql = "select u.id,u.email from " . DB_PREFIX . "user as u where u.email <> '' ";
                         if ($group_id > 0) {
                             $sql .= " and u.group_id = " . $group_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['email'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     break;
                 case 1:
                     //会员等级
                     $level_id = intval($promote_msg['send_type_id']);
                     if ($promote_msg['type'] == 0) {
                         //短信
                         $sql = "select u.id,u.mobile from " . DB_PREFIX . "user as u where u.mobile <> '' ";
                         if ($level_id > 0) {
                             $sql .= " and u.level_id = " . $level_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['mobile'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     if ($promote_msg['type'] == 1) {
                         //邮件
                         $sql = "select u.id,u.email from " . DB_PREFIX . "user as u where u.email <> '' ";
                         if ($level_id > 0) {
                             $sql .= " and u.level_id = " . $level_id;
                         }
                         $sql .= " and u.id > " . $last_id . " order by u.id asc";
                         $res = $GLOBALS['db']->getRow($sql);
                         $dest = $res['email'];
                         $uid = $res['id'];
                         $last_id = $res['id'];
                     }
                     break;
                 case 2:
                     //自定义
                     $send_define_data = trim($promote_msg['send_define_data']);
                     //自定义的内容
                     $dest_array = preg_split("/[ ,]/i", $send_define_data);
                     foreach ($dest_array as $k => $v) {
                         $rs = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "promote_msg_list where msg_id = " . intval($promote_msg['id']) . " and dest = '" . $v . "'");
                         if ($rs == 0) {
                             $dest = $v;
                             break;
                         }
                     }
                     $last_id = 0;
                     break;
             }
             if ($dest) {
                 //开始创建一个新的发送队列
                 $msg_data['dest'] = $dest;
                 $msg_data['send_type'] = $promote_msg['type'];
                 $msg_data['content'] = addslashes($promote_msg['content']);
                 $msg_data['title'] = $promote_msg['title'];
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = NOW_TIME;
                 $msg_data['user_id'] = intval($uid);
                 $msg_data['is_html'] = $promote_msg['is_html'];
                 $msg_data['msg_id'] = $promote_msg['id'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "promote_msg_list", $msg_data);
                 //插入
                 if ($id = $GLOBALS['db']->insert_id()) {
                     $msg_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "promote_msg_list where id = " . $id);
                     if ($msg_item) {
                         //优先改变发送状态,不论有没有发送成功
                         $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_send = 1,send_time='" . NOW_TIME . "' where id =" . intval($msg_item['id']));
                         if ($msg_item['send_type'] == 0) {
                             //短信
                             require_once APP_ROOT_PATH . "system/utils/es_sms.php";
                             $sms = new sms_sender();
                             $result = $sms->sendSms($msg_item['dest'], $msg_item['content']);
                             //发送结束,更新当前消息状态
                             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_success = " . intval($result['status']) . ",result='" . $result['msg'] . "' where id =" . intval($msg_item['id']));
                         }
                         if ($msg_item['send_type'] == 1) {
                             //邮件
                             require_once APP_ROOT_PATH . "system/utils/es_mail.php";
                             $mail = new mail_sender();
                             $mail->AddAddress($msg_item['dest']);
                             $mail->IsHTML($msg_item['is_html']);
                             // 设置邮件格式为 HTML
                             $mail->Subject = $msg_item['title'];
                             // 标题
                             $mail->Body = $msg_item['content'];
                             // 内容
                             $is_success = $mail->Send();
                             $result = $mail->ErrorInfo;
                             //发送结束,更新当前消息状态
                             $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg_list set is_success = " . intval($is_success) . ",result='" . $result . "' where id =" . intval($msg_item['id']));
                         }
                     }
                 }
                 $GLOBALS['db']->query("update " . DB_PREFIX . "conf set value = " . intval($last_id) . " where name='PROMOTE_MSG_PAGE'");
             } else {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "promote_msg set send_status = 2 where id = " . intval($promote_msg['id']));
                 $GLOBALS['db']->query("update " . DB_PREFIX . "conf set value = 0 where name='PROMOTE_MSG_PAGE'");
             }
         }
         $count = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "promote_msg where send_status <> 2 and send_time <=" . get_gmtime()));
         $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 0 where name = 'PROMOTE_MSG_LOCK'");
     } else {
         $count = 0;
     }
     $data['count'] = $count;
     ajax_return($data, true);
 }
 public function mail_demo($mail)
 {
     $test_mail = $mail;
     require_once APP_ROOT_PATH . "system/utils/es_mail.php";
     $mail = new mail_sender();
     $demo_html = file_get_contents(APP_ROOT_PATH . "public/mail_html/demo.html");
     $info = array();
     $info['content'] = "测试邮件";
     $info['logo'] = app_conf("SITE_LOGO");
     $info['site_name'] = app_conf("SITE_NAME");
     $time = get_gmtime();
     $info['send_time'] = to_date($time, 'Y年m月n日');
     $GLOBALS['tmpl']->assign("info", $info);
     $msg = $GLOBALS['tmpl']->fetch("str:" . $demo_html);
     $mail->AddAddress($test_mail);
     $mail->IsHTML(true);
     // 设置邮件格式为 HTML
     $mail->Subject = l("DEMO_MAIL");
     // 标题
     $mail->Body = $msg;
     // 内容
     $status = $mail->Send();
     $result = array('status' => 1, 'info' => '');
     if (!$status) {
         $result['status'] = 0;
         $result['info'] = $mail->ErrorInfo;
     }
     return $result;
 }