public function view_replyMessage()
 {
     $msgid = isset($_POST['msgid']) ? $_POST['msgid'] : 0;
     //回复的message
     $text = isset($_POST['text']) ? trim($_POST['text']) : '';
     //回复的内容
     $iscopy = isset($_POST['copy']) ? trim($_POST['copy']) : 1;
     //是否抄送到用户邮箱
     $hasattach = isset($_POST['hasattach']) ? trim($_POST['hasattach']) : '';
     $msg_obj = new amazonmessageModel();
     $account_obj = new AmazonAccountModel();
     $messageinfo = $msg_obj->getMessageInfo(array($msgid));
     if (empty($messageinfo)) {
         //message不存在
         $msgdata = array('errCode' => 10010, 'errMsg' => 'message不存在');
         echo json_encode($msgdata);
         exit;
     }
     if (empty($text)) {
         $msgdata = array('errCode' => 10013, 'errMsg' => '回复内容不能为空!');
         echo json_encode($msgdata);
         exit;
     }
     $msginfo = $messageinfo[0];
     $pwd = $account_obj->getAmazonPasswordByGmail($msginfo['recieveid'])[0]['password'];
     $pwd = base64_decode($pwd);
     $newid = 0;
     //新的队列主键id
     $doresult = $msg_obj->insertMessageReply($msgid, $iscopy, $text, $msginfo['classid'], $msginfo['amazon_account'], $newid);
     $connection = new AMQPConnection(MQ_SERVER, 5672, 'admin', 'admin', 'valsun_message');
     $channel = $connection->channel();
     $channel->exchange_declare(MQ_EXCHANGE_AMAZON, 'fanout', false, true, false);
     $channel->queue_declare(MQ_QUEUE_AMAZON, false, true, false, false);
     $send = preg_split('/@/', $recieveid)[0];
     $msg_uid = preg_replace("/{$send}/", '', $msginfo['message_id']);
     if ($hasattach == 'yes') {
         $attach = $msginfo['send_attachpath'];
     } else {
         if ($hasattach == 'no') {
             $attach = '';
         }
     }
     $text = '<pre>' . $text . '</pre>';
     $data = json_encode(array('mid' => $msgid, 'msgbody' => $text, 'subject' => $msginfo['subject'], 'sendid' => $msginfo['sendid'], 'recieveid' => $msginfo['recieveid'], 'pwd' => $pwd, 'attach' => $attach, 'msg_uid' => $msg_uid));
     $msg = new AMQPMessage($data, array('delivery_mode' => 2));
     //消息持久化
     $channel->basic_publish($msg, MQ_EXCHANGE_AMAZON);
     $channel->close();
     $connection->close();
     if ($doresult == TRUE) {
         $msgdata = array('errCode' => 10011, 'errMsg' => '操作成功!');
         echo json_encode($msgdata);
         exit;
     } else {
         $msgdata = array('errCode' => 10012, 'errMsg' => '操作失败!');
         echo json_encode($msgdata);
         exit;
     }
 }
<?php

/*
 * Amazon邮件抓取脚本
 */
error_reporting(E_ALL);
include_once __DIR__ . '/../framework.php';
// 加载框架
Core::getInstance();
// 初始化框架对象
include_once WEB_PATH . 'lib/Get_Email.class.php';
include_once WEB_PATH . 'lib/opensys_functions.php';
$mail = new Get_Email();
$account_obj = new AmazonAccountModel();
$msg_obj = new amazonmessageModel();
$msgcat_obj = new amazonmessagecategoryModel();
$fam_obj = new FetchAmazonMessageModel();
$accounts = $account_obj->getAmazonAccountsGmail();
$path = '';
$connect = array();
$n = 0;
foreach ($accounts as $ac) {
    if ($ac['amazon_account'] != "{$argv['1']}") {
        continue;
    }
    $path = WEB_PATH . 'crontab/gmaillib/' . $ac['amazon_account'] . '/' . preg_split('/@/', $ac['gmail'])[0] . '/' . date('Y-m-d') . '/';
    $connect = $mail->mailConnect('imap.gmail.com', '993', $ac['gmail'], base64_decode($ac['password']), 'INBOX', 'ssl');
    if (!$connect) {
        die('连接失败');
    } else {
        echo "连接成功\r\n";