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);
    $corpo = str_replace('{Delete}', '', $corpo);
    $corpo = str_replace('{Decimal}', '', $corpo);
    $corpo = str_replace('{Up}', '', $corpo);
    $corpo = str_replace('{Right}', '', $corpo);
    $corpo = str_replace('{Left}', '', $corpo);
    echo "Assunto: " . $head['subject'] . "<br>";
    echo "Para: " . $head['to'] . "<br>";
    echo "Para: " . $head['toOth'] . "<br>";
    echo "Para Nome: " . $head['toNameOth'] . "<br>";
    echo "De: " . $head['from'] . "<br>";
 /**
  * ]@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');
 }
示例#3
0
文件: users.php 项目: armpit/e107
 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);
 }
示例#4
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;
 }
示例#5
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);
     }
 }
示例#6
0
 */
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>";
	echo "<br>*******************************************************************************************<BR>";
	echo $obj->getBody($i);  // Get Body Of Mail number Return String Get Mail id in interger
	
	$str=$obj->GetAttach($i,"./"); // Get attached File from Mail Return name of file in comma separated string  args. (mailid, Path to store file)
	$ar=explode(",",$str);
	foreach($ar as $key=>$value)
		echo ($value=="")?"":"Atteched File :: ".$value."<br>";
	echo "<br>------------------------------------------------------------------------------------------<BR>";
示例#7
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();