Exemplo n.º 1
0
<?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";
Exemplo n.º 2
0
date_default_timezone_set('PRC');
$connection = new AMQPConnection(MQ_SERVER, 5672, MQ_USER, MQ_PSW);
$channel = $connection->channel();
$channel->exchange_declare(MQ_EXCHANGE_AMAZON, 'fanout', false, true, false);
//$channel->basic_qos(null, 1, null);//该设置让一个繁忙中的消费者不再接收邮件
//list($queue_name, ,) = $channel->queue_declare("message", false, false, true, false);
$channel->queue_declare(MQ_QUEUE_AMAZON, false, true, false, false);
$channel->queue_bind(MQ_QUEUE_AMAZON, MQ_EXCHANGE_AMAZON);
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
$callback = function ($msg) {
    //$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
    $msg_obj = new amazonmessageModel();
    $ms = json_decode($msg->body, true);
    var_dump($msg_obj);
    extract($ms);
    $mail_get = new Get_Email();
    $receive = preg_split('/@/', $sendid)[0];
    $send = preg_split('/@/', $recieveid)[0];
    //$message_id = $msg_obj->getMessageId($mid);  //message表中的message_id
    $msg_uid = preg_replace("/{$send}/", '', $msg_obj->getMessageId($mid)['message_id']);
    echo "The Next\n";
    $connect = $mail_get->mailConnect('imap.gmail.com', '993', "{$recieveid}", "{$pwd}", 'INBOX', 'ssl');
    //$msgno=imap_msgno($connect, $massage_id);
    $mail = new PHPMailer();
    //建立邮件发送类
    $mail->SMTPDebug = 1;
    $mail->CharSet = "UTF-8";
    $mail->IsSMTP();
    // 设定使用SMTP服务
    $mail->SMTPAuth = true;
    // 启用 SMTP 验证功能