Exemplo n.º 1
0
 public function receve($user_id = null, $background = false)
 {
     if (empty($user_id)) {
         $user_id = get_user_id();
     }
     $mail_account = $this->_get_mail_account($user_id);
     $new = 0;
     session_write_close();
     import("@.ORG.Util.receve");
     $mail_list = array();
     $mail = new receiveMail();
     $connect = $mail->connect($mail_account['pop3svr'], '110', $mail_account['mail_id'], $mail_account['mail_pwd'], 'INBOX', 'pop3/novalidate-cert');
     if (!$connect) {
         $connect = $mail->connect($mail_account['pop3svr'], '995', $mail_account['mail_id'], $mail_account['mail_pwd'], 'INBOX', 'pop3/ssl/novalidate-cert');
     }
     $mail_count = $mail->mail_total_count();
     if ($connect) {
         for ($i = 1; $i <= $mail_count; $i++) {
             $mail_id = $mail_count - $i + 1;
             $item = $mail->mail_list($mail_id);
             $where = array();
             $where['user_id'] = $user_id;
             if (empty($item[$mail_id])) {
                 $temp_mail_header = $mail->mail_header($mail_id);
                 $where['mid'] = $temp_mail_header['mid'];
             } else {
                 $where['mid'] = $item[$mail_id];
             }
             $count = M('Mail')->where($where)->count();
             if ($count == 0) {
                 $model = M("Mail");
                 $model->create($mail->mail_header($mail_id));
                 if ($model->create_time < strtotime(date('y-m-d h:i:s')) - 86400 * 30) {
                     $mail->close_mail();
                     if ($new > 0) {
                         $this->_pushReturn($new, "收到" . $new . "封邮件", 1);
                     }
                     return;
                 }
                 $new++;
                 $model->user_id = $user_id;
                 $model->read = 0;
                 $model->folder = 1;
                 $model->is_del = 0;
                 $str = $mail->get_attach($mail_id, $this->tmpPath);
                 $model->add_file = $this->_receive_file($str, $model);
                 $this->_organize($model);
                 $model->add();
             } else {
                 if (!$background) {
                     if ($new == 0) {
                         $this->_pushReturn($new, "没有新邮件", 1);
                         return;
                     }
                 }
                 $mail->close_mail();
             }
         }
     }
     $mail->close_mail();
     $this->_pushReturn($new, "收到" . $new . "封邮件", 1);
     return;
 }
Exemplo n.º 2
0
 public function receve()
 {
     $new = 0;
     if ($this->_check_mail_account() == false) {
         $this->ajaxReturn(1, "请设置邮箱帐号", 0);
         die;
     }
     $user_id = get_user_id();
     session_write_close();
     vendor("Mail.class#receve2");
     $mail_list = array();
     $mail = new receiveMail();
     $connect = $mail->connect($this->_account['pop3svr'], '110', $this->_account['mail_id'], $this->_account['mail_pwd'], 'INBOX', 'pop3');
     $mail_count = $mail->mail_total_count();
     if ($connect) {
         for ($i = 1; $i < $mail_count; $i++) {
             $mail_id = $mail_count - $i + 1;
             $item = $mail->mail_list($mail_id);
             $where = array();
             $where['user_id'] = $user_id;
             $where['mid'] = $item[$mail_id];
             $count = M('Mail')->where($where)->count();
             if (empty($item[$mail_id])) {
                 //mid 空时当成新邮件处理
                 $count = 0;
             }
             if ($count == 0) {
                 $new++;
                 $model = M("Mail");
                 $model->create($mail->mail_header($mail_id));
                 if ($model->create_time < strtotime(date('y-m-d h:i:s')) - 86400 * 30) {
                     $mail->close_mail();
                     $this->pushReturn($new, "收到" . $new . "封邮件", 1);
                 }
                 $model->user_id = $user_id;
                 $model->read = 0;
                 $model->folder = 1;
                 $model->is_del = 0;
                 $str = $mail->get_attach($mail_id, $this->tmpPath);
                 $model->add_file = $this->_receive_file($str, $model);
                 $this->organize($model);
                 $model->add();
             } else {
                 $mail->close_mail();
                 if ($new == 0) {
                     $this->pushReturn($new, "没有新邮件", 1);
                 }
             }
         }
     }
     $mail->close_mail();
     $this->pushReturn($new, "收到" . $new . "封邮件", 1);
     //$this -> ajaxReturn($new, "收到" . $new . "封邮件", 1);
 }
 /**
  * ]@Title: lookupgetbody 
  * @Description: todo(邮件的直接查看,收件箱右边显示的内容)   
  * @author xiafengqin 
  * @date 2013-9-3 下午3:01:32 
  * @throws
  */
 public function lookupgetbody()
 {
     $mid = $_REQUEST['mid'];
     //获取当前人的外部邮箱的相关配置
     $configEmailModel = D('MisSystemEmail');
     $this->assign('downdataid', $mid - 1);
     //上一条
     $this->assign('updataid', $mid + 1);
     //上一条
     if ($_REQUEST['isUpDown'] == 'prev') {
         $this->assign('downdataid', $mid + 1);
         //上一条
         $mid = $mid - 1;
     }
     if ($_REQUEST['isUpDown'] == 'next') {
         $this->assign('updataid', $mid + 1);
         //下一条
         $mid = $mid + 1;
     }
     $map = array();
     $map['status'] = 1;
     $map['defaultemail'] = 1;
     $map['userid'] = $_SESSION[C('USER_AUTH_KEY')];
     $vo = $configEmailModel->where($map)->find();
     //引入并实例化receivemail这个类
     import("@.ORG.Mailer.receivemail");
     $obj = new receiveMail('*****@*****.**', '75522610826', '*****@*****.**', 'pop.163.com', 'pop3', '110', false);
     $obj->connect();
     //If connection fails give error message and exit
     $tot = $obj->getTotalMails();
     //Total Mails in Inbox Return integer value
     $mid = $tot - ($mid - 1);
     $head = $obj->getHeaders($mid);
     // Get Header Info Return Array Of Headers **Array Keys are (subject,to,toOth,toNameOth,from,fromName)
     $new['title'] = $head['subject'];
     $new['recipient'] = $head['to'];
     //收件人
     $new['copytopeopleid'] = $head['toOth'];
     //抄送人
     $new['createid'] = $head['from'];
     //发件人
     $new['emaildate'] = $head['date'];
     //邮件接收时间
     $new['content'] = $this->test($obj->getBody($mid));
     $str = $obj->GetAttach($mid, "./");
     // Get attached File from Mail Return name of file in comma separated string  args. (mailid, Path to store file)
     $new['attr'] = explode(",", $str);
     $this->assign('default', $new);
     $this->display('lookupreadmessage');
 }
Exemplo n.º 4
0
                $mes = '11';
                break;
            case 'Dec':
                $mes = '12';
                break;
        }
        $dia = $data[2] < 10 ? '0' . $data[2] : $data[2];
        $data = $data[4] . ':' . $mes . ':' . $dia . ' ' . $data[5];
        echo $data . "<br/>";
        print_r($headers);
        echo '<br /><br />';
    }
}
exit;
include "../emails/receivemail.class.php";
$obj = new receiveMail('suporte+cartoriopostal.com.br', 'a123d321', '*****@*****.**', 'mail.cartoriopostal.com.br', 'imap', '143/novalidate-cert', false);
$obj->connect();
$tot = $obj->getTotalMails();
echo "Total Mails:: {$tot}<br>";
$cont = 0;
for ($i = $tot; $i > 0; $i--) {
    if ($cont == 20) {
        break;
    }
    $cont++;
    $head = $obj->getHeaders($i);
    $corpo = str_replace('{Down}', '', $obj->getBody($i));
    $corpo = str_replace('{Back}', '', $corpo);
    $corpo = str_replace('{Escape}', '', $corpo);
    $corpo = str_replace('{Tab}', '', $corpo);
    $corpo = str_replace('{LMenu}', '', $corpo);
Exemplo n.º 5
0
 /**
  * Parse Invitation Email from Picasa
  **/
 function getEmail()
 {
     // Require DB & Email Config
     require_once "../lib/picasa/receivemail.class.php";
     require_once "../lib/picasa/config.php";
     // Create an instance of ADO connection object
     $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
     // Define connection string, specify database driver
     $connStr = "PROVIDER=SQLOLEDB;SERVER=" . $server . ";UID=" . $username . ";PWD=" . $passwd . ";DATABASE=" . $db;
     $conn->open($connStr);
     //Open the connection to the database
     // Create Object For reciveMail Class
     $obj = new receiveMail($uemail, $pemail, $email, $eserver, $etype, $eport);
     //Connect to the Mail Box
     $obj->connect();
     // Get Total Number of Unread Email in mail box
     $total = $obj->getTotalMails();
     //Total Mails in Inbox Return integer value
     $emailArray = array();
     for ($i = 1; $i <= $total; $i++) {
         $content = $obj->getBody($i);
         $lines = preg_split("/\r?\n|\r/", $content);
         // turn the content into rows
         $links_regex = '#<a[^/>]*' . 'href=["|\']([^javascript:].*)["|\']#Ui';
         //regular expression to extract url from html links
         $searchString = $lines[31];
         // check if line number 31 contains a link.
         $findString = "<a href";
         $pos = strpos($searchString, $findString);
         if ($pos === false) {
             preg_match_all($links_regex, $lines[35], $out, PREG_PATTERN_ORDER);
             //if line 31 did not contains link than use line 35 to process regex
         } else {
             preg_match_all($links_regex, $lines[31], $out, PREG_PATTERN_ORDER);
             //use line 31 to process regex
         }
         $emailItem = array();
         $vars = explode("?", $out[1][0]);
         $splitVars = explode("&", $vars[1]);
         for ($j = 0; $j < 4; $j++) {
             array_push($emailItem, $this->_getVal($splitVars[$j]));
         }
         array_push($emailArray, $emailItem);
         //declare the SQL statement that will query the database
         $query = "INSERT INTO tbl_picasa ( username, type, type_id, authkey ) \n\t\t\t\t\t\t\t\tVALUES ( '" . $this->_getVal($splitVars[0]) . "', '" . $this->_getVal($splitVars[1]) . "', '" . $this->_getVal($splitVars[2]) . "', '" . $this->_getVal($splitVars[3]) . "' )";
         //print_r($query);
         //execute the SQL statement and return records
         $rs = $conn->execute($query);
         $obj->deleteMails($i);
         // Delete Mail from Mail box
     }
     $obj->close_mailbox();
     //Close Mail Box
     if ($total > 0) {
         return $emailArray;
     } else {
         return $total;
     }
 }
Exemplo n.º 6
0
 function check_bounces($bounce_act = 'first_check', $bounce_arr = '')
 {
     ### old Trigger code for bounce check
     // $bounce_act = '';
     // if (isset ($_POST['check_bounces']))
     // $bounce_act = 'first_check';
     // if (isset ($_POST['delnonbouncesubmit']))
     // $bounce_act = 'delnonbounce';
     // if (isset ($_POST['clearemailbouncesubmit']))
     // $bounce_act = 'clearemailbounce';
     // if (isset ($_POST['delcheckedsubmit']))
     // $bounce_act = 'delchecked';
     // if (isset ($_POST['delallsubmit']))
     // $bounce_act = 'delall';
     // if ($bounce_act)
     // {
     // $user->check_bounces($bounce_act,implode(',',$_POST['delete_email']));
     // require_once ("footer.php");
     // exit;
     // }
     global $sql, $pref;
     include e_HANDLER . 'pop3_class.php';
     if (!trim($bounce_act)) {
         $bounce_act = 'first_check';
     }
     //	  echo "Check bounces. Action: {$bounce_act}; Entries: {$bounce_arr}<br />";
     $obj = new receiveMail($pref['mail_bounce_user'], $pref['mail_bounce_pass'], $pref['mail_bounce_email'], $pref['mail_bounce_pop3'], varset($pref['mail_bounce_type'], 'pop3'));
     $del_count = 0;
     if ($bounce_act != 'first_check') {
         // Must do some deleting
         $obj->connect();
         $tot = $obj->getTotalMails();
         $del_array = explode(',', $bounce_arr);
         for ($i = 1; $i <= $tot; $i++) {
             // Scan all emails; delete current one if meets the criteria
             $dodel = false;
             switch ($bounce_act) {
                 case 'delnonbounce':
                     $head = $obj->getHeaders($i);
                     $dodel = !$head['bounce'];
                     break;
                 case 'clearemailbounce':
                     if (!in_array($i, $del_array)) {
                         break;
                     }
                     $head = $obj->getHeaders($i);
                     if ($head['bounce']) {
                         if (preg_match("/[\\._a-zA-Z0-9-]+@[\\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) {
                             $usr_email = trim($result[0]);
                         }
                         if ($sql->db_Select('user', 'user_id, user_name, user_email', "user_email='" . $usr_email . "' ")) {
                             $row = $sql->fetch();
                             if ($sql->db_Update('user', "`user_email`='' WHERE `user_id` = '" . $row['user_id'] . "' ") !== false) {
                                 // echo "Deleting user email {$row['user_email']} for user {$row['user_name']}, id={$row['user_id']}<br />";
                                 $dodel = true;
                             }
                         }
                     }
                     break;
                 case 'delall':
                     $dodel = true;
                     break;
                 case 'delchecked':
                     $dodel = in_array($i, $del_array);
                     break;
             }
             if ($dodel) {
                 //			  echo "Delete email ID {$i}<br />";
                 $obj->deleteMails($i);
                 $del_count++;
                 // Keep track of number of emails deleted
             }
         }
         // End - Delete one email
         $obj->close_mailbox();
         // This actually deletes the emails
     }
     // End of email deletion
     // Now list the emails that are left
     $obj->connect();
     $tot = $obj->getTotalMails();
     $found = false;
     $DEL = $pref['mail_bounce_delete'] ? true : false;
     $text = "<br /><div><form  method='post' action='" . e_SELF . $qry . "'><table>\r\n\t\t<tr><td style='width:5%'>#</td><td>e107-id</td><td>email</td><td>Subject</td><td>Bounce</td></tr>\n";
     $identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id');
     for ($i = 1; $i <= $tot; $i++) {
         $head = $obj->getHeaders($i);
         if ($head['bounce']) {
             // Its a 'bounce' email
             if (preg_match('/.*' . $identifier . ':(.*)MIME/', $obj->getBody($i), $result)) {
                 if ($result[1]) {
                     $id[$i] = intval($result[1]);
                     // This should be a user ID - but not on special mailers!
                     //	Try and pull out an email address from body - should be the one that failed
                     if (preg_match("/[\\._a-zA-Z0-9-]+@[\\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) {
                         $emails[$i] = "'" . $result[0] . "'";
                     }
                     $found = true;
                 }
             } elseif (preg_match("/[\\._a-zA-Z0-9-]+@[\\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) {
                 if ($result[0] && $result[0] != $pref['mail_bounce_email']) {
                     $emails[$i] = "'" . $result[0] . "'";
                     $found = true;
                 } elseif ($result[1] && $result[1] != $pref['mail_bounce_email']) {
                     $emails[$i] = "'" . $result[1] . "'";
                     $found = true;
                 }
             }
             if ($DEL && $found) {
                 // Auto-delete bounced emails once noticed (if option set)
                 $obj->deleteMails($i);
                 $del_count++;
             }
         } else {
             // Its a warning message or similar
             //			  $id[$i] = '';			// Don't worry about an ID for now
             //				Try and pull out an email address from body - should be the one that failed
             if (preg_match("/[\\._a-zA-Z0-9-]+@[\\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) {
                 $wmails[$i] = "'" . $result[0] . "'";
             }
         }
         $text .= "<tr><td>" . $i . "</td><td>" . $id[$i] . "</td><td>" . (isset($emails[$i]) ? $emails[$i] : $wmails[$i]) . "</td><td>" . $head['subject'] . "</td><td>" . ($head['bounce'] ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON);
         $text .= "<input type='checkbox' name='delete_email[]' value='{$i}' /></td></tr>\n";
     }
     if ($del_count) {
         e107::getLog()->add('USET_13', str_replace('--COUNT--', $del_count, USRLAN_169), E_LOG_INFORMATIVE);
     }
     if ($tot) {
         // Option to delete emails - only if there are some in the list
         $text .= "</table><table style='" . ADMIN_WIDTH . "'><tr>\r\n\t\t\t<td style='text-align: center;'><input class='btn btn-default button' type='submit' name='delnonbouncesubmit' value='" . USRLAN_183 . "' /></td>\n\r\n\t\t\t<td style='text-align: center;'><input class='btn btn-default button' type='submit' name='clearemailbouncesubmit' value='" . USRLAN_184 . "' /></td>\n\r\n\t\t\t<td style='text-align: center;'><input class='btn btn-default button' type='submit' name='delcheckedsubmit' value='" . USRLAN_179 . "' /></td>\n\r\n\t\t\t<td style='text-align: center;'><input class='btn btn-default button' type='submit' name='delallsubmit' value='" . USRLAN_180 . "' /></td>\n\r\n\t\t\t</td></tr>";
     }
     $text .= "</table></form></div>";
     array_unique($id);
     array_unique($emails);
     $all_ids = implode(',', $id);
     $all_emails = implode(',', $emails);
     $obj->close_mailbox();
     // This will actually delete emails
     // $tot has total number of emails in the mailbox
     $found = count($emails);
     // $found - Number of bounce emails found
     // $del_count has number of emails deleted
     // Update bounce status for users
     $ed = $sql->db_Update('user', "user_ban=3 WHERE (`user_id` IN (" . $all_ids . ") OR `user_email` IN (" . $all_emails . ")) AND user_sess !='' ");
     if (!$ed) {
         $ed = '0';
     }
     $this->show_message(str_replace(array('{TOTAL}', '{DELCOUNT}', '{DELUSER}', '{FOUND}'), array($tot, $del_count, $ed, $found), USRLAN_155) . $text);
 }
Exemplo n.º 7
0
 /**
 +----------------------------------------------------------
 * 邮件接收
 * author:yangxi
 * data:20130812
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 receiveMail‘s mothod
 $username      = User name off the mail box
 $password      = Password of mailbox
 $emailAddress  = Email address of that mailbox some time the uname and email address are identical
 $mailserver    = Ip or name of the POP or IMAP mail server
 $servertype    = if this server is imap or pop default is pop
 $port          = Server port for pop or imap Default is 110 for pop and 143 for imap
 +----------------------------------------------------------
 * @return  string
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function ReceiveEmail($username, $password, $emailAddress = '', $mailserver, $servertype, $port)
 {
     import("@.ORG.Mailer.receivemail");
     $obj = new receiveMail($username, $password, $emailAddress, $mailserver, $servertype, $port);
     $obj->connect();
     //建立连接
     $tot = $obj->getTotalMails();
     //获取条数
     $emailArr = array();
     for ($i = $tot; $i > 0; $i--) {
         $new = array();
         $head = $obj->getHeaders($i);
         // Get Header Info Return Array Of Headers **Array Keys are (subject,to,toOth,toNameOth,from,fromName)
         $new['title'] = $this->test($head['subject']);
         $new['recipient'] = $head['to'];
         //收件人
         $new['copytopeopleid'] = $head['toOth'];
         //抄送人
         $new['createid'] = $head['from'];
         //发件人
         $new['emaildate'] = $head['date'];
         //邮件接收时间
         $new['message_id'] = $head['message_id'];
         //邮件唯一标识
         //	$new['content'] = $this->test($obj->getBody($i));
         $str = $obj->GetAttach($i, "./");
         // Get attached File from Mail Return name of file in comma separated string  args. (mailid, Path to store file)
         $new['attr'] = explode(",", $str);
         $emailArr[] = $new;
         //$obj->deleteMails($i); // Delete Mail from Mail box
     }
     $obj->close_mailbox();
     //Close Mail Box
     return $emailArr;
 }
Exemplo n.º 8
0
 protected function _mailTime()
 {
     //        dump($_SERVER['DOCUMENT_ROOT'].__ROOT__);
     //        exit;
     include $_SERVER['DOCUMENT_ROOT'] . __ROOT__ . "/Public/receivemail.class.php";
     $uid = get_user_id();
     if (D('mail_time')->where('uid=' . $uid)->find()) {
         $time = D('mail_time')->where('uid=' . $uid)->getField('time');
         D('mail_time')->where('uid=' . $uid)->setField('time', time());
     } else {
         $time = time();
         $mail_time['uid'] = $uid;
         $mail_time['time'] = time();
         D('mail_time')->add($mail_time);
     }
     $mailAccount = D('mail_account')->where('id=' . $uid)->find();
     $obj = new receiveMail($mailAccount['email'], $mailAccount['mail_pwd'], $mailAccount['email'], $mailAccount['pop3svr'], 'pop3', '110', false);
     $obj->connect();
     $tot = $obj->getTotalMails();
     for ($i = $tot; $i > 0; $i--) {
         $head = $obj->getHeaders($i);
         if ($head['udate'] < $time) {
             continue;
         }
         $data = array();
         $data['folder'] = 1;
         $data['name'] = iconv($head['subject_charset'], 'UTF-8', $head['subject']);
         $data['content'] = $obj->getBody($i);
         $data['wai1'] = iconv('GBK', 'UTF-8', $head['from']);
         $data['create_time'] = $head['udate'];
         $data['user_id'] = $uid;
         D('mail')->add($data);
     }
 }
Exemplo n.º 9
0
<?
/*
 * File: example.php
 * Description: Received Mail Example
 * Created: 01-03-2006
 * Author: Mitul Koradia
 * Email: mitulkoradia@gmail.com
 * Cell : +91 9825273322
 */
include("receivemail.class.php");
// Creating a object of reciveMail Class
$obj= new receiveMail('upload','Kbxf*#nO;gW$','*****@*****.**','mail.bcmoney-mobiletv.com','pop3','110',false);

//Connect to the Mail Box
$obj->connect();         //If connection fails give error message and exit

// Get Total Number of Unread Email in mail box
$tot=$obj->getTotalMails(); //Total Mails in Inbox Return integer value

echo "Total Mails:: $tot<br>";

for($i=$tot;$i>0;$i--)
{
	$head=$obj->getHeaders($i);  // Get Header Info Return Array Of Headers **Array Keys are (subject,to,toOth,toNameOth,from,fromName)
	echo "Subjects :: ".$head['subject']."<br>";
	echo "TO :: ".$head['to']."<br>";
	echo "To Other :: ".$head['toOth']."<br>";
	echo "ToName Other :: ".$head['toNameOth']."<br>";
	echo "From :: ".$head['from']."<br>";
	echo "FromName :: ".$head['fromName']."<br>";
	echo "<br><br>";
Exemplo n.º 10
0
<?php

include "mail.class.php";
$obj = new receiveMail('邮箱地址', '客户端授权码', 'imap.163.com', 'imap', '993', true);
$obj->connect();
$emails = $obj->getTotalMails('NEW');
//NEW 获取最新未读的 ALL 获取所有的
echo "Total Mails:: " . count($emails) . PHP_EOL . PHP_EOL;
if ($emails) {
    foreach ($emails as $email) {
        $head = $obj->getHeaders($email);
        echo "Subjects :: " . $head['subject'] . PHP_EOL;
        echo "TO :: " . $head['to'] . PHP_EOL;
        echo "To Other :: " . $head['toOth'] . PHP_EOL;
        echo "ToName Other :: " . $head['toNameOth'] . PHP_EOL;
        echo "From :: " . $head['from'] . PHP_EOL;
        echo "FromName :: " . $head['fromName'] . PHP_EOL;
        //echo "Message Content ::".$obj->getBody($email);
        $files = $obj->GetAttach($email, "./");
        foreach ($files as $value) {
            echo "Atteched File :: " . $value . PHP_EOL;
        }
        echo "*******************************************************************************************" . PHP_EOL;
        //$obj->deleteMails($email);
    }
}
$obj->close_mailbox();