/**
  * ]@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');
 }
Пример #2
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;
     }
 }
Пример #3
0
    }
}
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>";
    echo "De Nome: " . $head['fromName'] . "<br>";
Пример #4
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);
 }
Пример #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
$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>";
	
	//$obj->deleteMails($i); // Delete Mail from Mail box
}
$obj->close_mailbox();   //Close Mail Box

?>