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; } }