コード例 #1
4
ファイル: ImapMessage.php プロジェクト: dabielkabuto/eventum
 /**
  * Method to read email from imap extension and return Zend Mail Message object.
  *
  * This is bridge while migrating to Zend Mail package supporting reading from imap extension functions.
  *
  * @param resource $mbox
  * @param integer $num
  * @param array $info connection information about connection
  * @return ImapMessage
  */
 public static function createFromImap($mbox, $num, $info)
 {
     // check if the current message was already seen
     list($overview) = imap_fetch_overview($mbox, $num);
     $headers = imap_fetchheader($mbox, $num);
     $content = imap_body($mbox, $num);
     // fill with "\Seen", "\Deleted", "\Answered", ... etc
     $knownFlags = array('recent' => Zend\Mail\Storage::FLAG_RECENT, 'flagged' => Zend\Mail\Storage::FLAG_FLAGGED, 'answered' => Zend\Mail\Storage::FLAG_ANSWERED, 'deleted' => Zend\Mail\Storage::FLAG_DELETED, 'seen' => Zend\Mail\Storage::FLAG_SEEN, 'draft' => Zend\Mail\Storage::FLAG_DRAFT);
     $flags = array();
     foreach ($knownFlags as $flag => $value) {
         if ($overview->{$flag}) {
             $flags[] = $value;
         }
     }
     $message = new self(array('root' => true, 'headers' => $headers, 'content' => $content, 'flags' => $flags));
     // set MailDate to $message object, as it's not available in message headers, only in IMAP itself
     // this likely "message received date"
     $imapheaders = imap_headerinfo($mbox, $num);
     $header = new GenericHeader('X-IMAP-UnixDate', $imapheaders->udate);
     $message->getHeaders()->addHeader($header);
     $message->mbox = $mbox;
     $message->num = $num;
     $message->info = $info;
     return $message;
 }
コード例 #2
2
 public function fetch($delete = false)
 {
     $oImap = imap_open('{' . $this->mail_server . ':993/imap/ssl/notls/novalidate-cert}', $this->username, $this->password);
     $oMailboxStatus = imap_check($oImap);
     $aMessages = imap_fetch_overview($oImap, "1:{$oMailboxStatus->Nmsgs}");
     $validMessages = array();
     foreach ($aMessages as $oMessage) {
         print "Trying message '" . $oMessage->subject . "'";
         $fileContent = $fileType = '';
         $geocoder = factory::create('geocoder');
         $postCode = $geocoder->extract_postcode($oMessage->subject);
         $fromName = null;
         $fromEmail = null;
         if (strpos($oMessage->from, '<')) {
             $split = split('<', $oMessage->from);
             //name - make sure name not an email address
             $fromName = trim($split[0]);
             if (valid_email($fromName)) {
                 $fromName = null;
             }
             //email
             $fromEmail = trim(str_replace('>', '', $split[1]));
         } else {
             $fromEmail = $oMessage->from;
         }
         $images = array();
         $messageStructure = imap_fetchstructure($oImap, $oMessage->msgno);
         if (isset($messageStructure->parts)) {
             $partNumber = 0;
             foreach ($messageStructure->parts as $oPart) {
                 $partNumber++;
                 if ($oPart->subtype == 'PLAIN' && !$postCode) {
                     $messageContent = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     if ($oPart->encoding == 4) {
                         $messageContent = quoted_printable_decode($messageContent);
                     }
                     $postCode = geocoder::extract_postcode($messageContent);
                 } elseif ($oPart->encoding == 3 && in_array($oPart->subtype, array('JPEG', 'PNG'))) {
                     $oImage = null;
                     $encodedBody = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
                     $fileContent = base64_decode($encodedBody);
                     $oImage = imagecreatefromstring($fileContent);
                     if (imagesx($oImage) > $this->min_import_size && imagesy($oImage) > $this->min_import_size) {
                         array_push($images, $oImage);
                     }
                     $fileType = strtolower($oPart->subtype);
                 }
             }
         }
         //add to the messages array
         array_push($validMessages, array('postcode' => $postCode, 'images' => $images, 'file_type' => $fileType, 'from_address' => $fromAddress, 'from_email' => $fromEmail, 'from_name' => $fromName));
         if ($delete) {
             imap_delete($oImap, $oMessage->msgno);
         }
     }
     imap_close($oImap, CL_EXPUNGE);
     $this->messages = $validMessages;
 }
コード例 #3
2
 function getdata($host, $login, $password, $savedirpath)
 {
     $mbox = imap_open($host, $login, $password) or die("can't connect: " . imap_last_error());
     $message = array();
     $message["attachment"]["type"][0] = "text";
     $message["attachment"]["type"][1] = "multipart";
     $message["attachment"]["type"][2] = "message";
     $message["attachment"]["type"][3] = "application";
     $message["attachment"]["type"][4] = "audio";
     $message["attachment"]["type"][5] = "image";
     $message["attachment"]["type"][6] = "video";
     $message["attachment"]["type"][7] = "other";
     $buzon_destino = "cfdi";
     echo imap_createmailbox($mbox, imap_utf7_encode("{$buzon_destino}"));
     echo imap_num_msg($mbox);
     for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++) {
         $structure = imap_fetchstructure($mbox, $jk);
         $parts = $structure->parts;
         $fpos = 2;
         for ($i = 1; $i < count($parts); $i++) {
             $message["pid"][$i] = $i;
             $part = $parts[$i];
             if (strtolower($part->disposition) == "attachment") {
                 $message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
                 $message["subtype"][$i] = strtolower($part->subtype);
                 $ext = $part->subtype;
                 $params = $part->dparameters;
                 $filename = $part->dparameters[0]->value;
                 if (!($ext == 'xml' or $ext == 'XML' or $ext == 'PDF' or $ext == 'pdf')) {
                     continue;
                 }
                 $mege = "";
                 $data = "";
                 $mege = imap_fetchbody($mbox, $jk, $fpos);
                 $data = $this->getdecodevalue($mege, $part->type);
                 $fp = fopen($filename, 'w');
                 fputs($fp, $data);
                 fclose($fp);
                 $fpos += 1;
                 /* Se mueve el archiv descargado al directorio de recibidos */
                 //                    rename($filename, $savedirpath.$filename);
                 //                    printf("\nSe movio el archivo $filename");
             }
         }
         $result = imap_fetch_overview($mbox, $jk);
         echo $result[0]->from;
         //            imap_mail_move($mbox, $jk, $buzon_destino);
         //imap_delete tags a message for deletion
         //    imap_delete($mbox,$jk);
     }
     // imap_expunge deletes all tagged messages
     //                    imap_expunge($mbox);
     imap_close($mbox);
 }
コード例 #4
1
 function inbox()
 {
     $this->msg_cnt = imap_num_msg($this->conn);
     echo "Number of emails read = " . $this->msg_cnt . "\n";
     /*$in = array();
     		for($i = 1; $i <= $this->msg_cnt; $i++) {
     			$in[] = array(
     				'index'     => $i,
     				'header'    => imap_headerinfo($this->conn, $i),
     				'body'      => imap_body($this->conn, $i),
     				'structure' => imap_fetchstructure($this->conn, $i)
     			); */
     $output = '<table>';
     $output .= '<tr><th>Subject</th><th>voucher</th><th>From</th><th>seen</th><th>type</th></tr>';
     $mails = imap_search($this->conn, 'FROM "*****@*****.**" SUBJECT "Confirm Hotel Booking"');
     //print_r($mails);
     for ($i = 0; $i <= sizeof($mails); $i++) {
         $header = imap_fetch_overview($this->conn, $mails[$i], 0);
         $body = imap_fetchbody($this->conn, $mails[$i], 1.1);
         $output .= '<tr>';
         $output .= '<td><span class="subject">' . $header[0]->subject . '</span> </td>';
         $output .= '<td><span class="from">' . $header[0]->from . '</span></td>';
         $output .= '<td><span class="voucher">' . $mails[0]->voucher . '</span></td>';
         $output .= '<td><span class="date">' . $header[0]->date . '</span></td>>';
         $output .= '<td><span class="toggler">' . ($header[0]->seen ? 'read' : 'unread') . '"></span></td>';
         $structure = imap_fetchstructure($this->conn, $mails[$i]);
         $output .= '<td><span class="type">' . $structure->type . '</span> </td>';
         $output .= '</tr>';
     }
     $output .= '</table>';
     echo $output . "\n";
 }
コード例 #5
1
 public function listNew($user_id, $filter)
 {
     $inbox = $this->getInbox($user_id);
     if ($filter == '') {
         $filter = 'UNSEEN';
     } else {
         $filter = 'UNSEEN CC "t' . $filter . '@' . $this->domain . '"';
     }
     $emails = imap_search($inbox, $filter);
     $msgs = array();
     $ids = array();
     for ($start = count($emails); $start > 0;) {
         $start--;
         $ids[] = $emails[$start];
     }
     $overviews = imap_fetch_overview($inbox, implode(',', $ids));
     foreach ($overviews as $overview) {
         $msg_no = $overview->msgno;
         $message = isset($overview->subject) ? $overview->subject : imap_fetchbody($inbox, $msg_no, '1');
         $from = $overview->from;
         if (($pos = strpos($from, '<')) !== FALSE) {
             $sender_name = substr($from, 0, $pos);
             $pos2 = strpos($from, '@', $pos);
             $sender_id = substr($from, $pos + 2, $pos2 - $pos - 2);
         }
         $msgs[] = array('id' => $msg_no, 'sender_id' => $sender_id, 'sender_name' => $sender_name, 'date' => $overview->udate, 'msg' => json_decode($message), 'seen' => $overview->seen);
     }
     $unreads = imap_search($inbox, "UNSEEN");
     if ($unreads) {
         imap_setflag_full($inbox, implode(',', $unreads), '\\Seen');
     }
     return $msgs;
 }
コード例 #6
0
ファイル: IMAPParser.php プロジェクト: Bridgeborn/Swiftriver
 /**
  * Gets IMAP content
  *
  * @param string $imapHost
  * @param string $imapUser
  * @param string $imapPassword
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  *
  * @return $contentItems[]
  */
 private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel)
 {
     $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword);
     //Open up unseen messages
     $imapEmails = imap_search($imapResource, strtoupper($channel->subType));
     $contentItems = array();
     if ($imapEmails) {
         //Put newest emails on top
         rsort($imapEmails);
         foreach ($imapEmails as $Email) {
             //Loop through each email and return the content
             $email_overview = imap_fetch_overview($imapResource, $Email, 0);
             $email_message = imap_fetchbody($imapResource, $Email, 2);
             $source_name = $imapUser;
             $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name);
             $source->name = $source_name;
             $source->parent = $channel->id;
             $source->type = $channel->type;
             $source->subType = $channel->subType;
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message));
             //the message
             $item->link = null;
             $item->date = $email_overview[0]->date;
             $contentItems[] = $item;
         }
         imap_close($imapResource);
         return $contentItems;
     }
     imap_close($imapResource);
     return null;
 }
コード例 #7
0
ファイル: SMW_DALReadPOP3.php プロジェクト: seedbank/old-repo
 public function getImportSets($dataSourceSpec)
 {
     $connection = $this->getConnection($dataSourceSpec);
     if ($connection == false) {
         return DAL_POP3_RET_ERR_START . wfMsg('smw_ti_pop3error') . DAL_POP3_RET_ERR_END;
     }
     $check = imap_check($connection);
     $messages = imap_fetch_overview($connection, "1:{$check->Nmsgs}", 0);
     $result = "";
     $names = array();
     foreach ($messages as $msg) {
         if (key_exists("from", $msg)) {
             $name = $msg->from;
             $startPos = strpos($name, "<") + 1;
             $endPos = strpos($name, ">") - $startPos;
             $names[substr($name, $startPos, $endPos)] = true;
         }
     }
     foreach ($names as $name => $dontCare) {
         $result .= '<importSet>' . "\n" . '	<name>' . $name . '</name>' . "\n" . '</importSet>' . "\n";
     }
     imap_close($connection);
     $this->connection = false;
     return '<?xml version="1.0"?>' . "\n" . '<ImportSets xmlns="http://www.ontoprise.de/smwplus#">' . "\n" . $result . '</ImportSets>' . "\n";
 }
コード例 #8
0
ファイル: MailCheckGUI.class.php プロジェクト: nemiah/fheME
 public function check($touch = false)
 {
     $mbox = $this->connection();
     #echo "<h1>Nachrichten in INBOX</h1><div style=\"overflow:auto;max-height:400px;\"><pre>";
     $MC = imap_check($mbox);
     $T = new HTMLTable(1, $touch ? "Mails" : "");
     $T->setTableStyle("font-size:11px;");
     $T->useForSelection();
     $start = $MC->Nmsgs - 10;
     if ($start < 1) {
         $start = 1;
     }
     $result = imap_fetch_overview($mbox, "{$start}:{$MC->Nmsgs}", 0);
     $result = array_reverse($result);
     foreach ($result as $overview) {
         #print_r($overview);
         $T->addRow(array("\n\t\t\t\t<small style=\"color:grey;float:right;\">" . Util::CLDateParser($overview->udate) . "</small>\n\t\t\t\t" . str_replace("\"", "", $this->decodeBlubb($overview->from)) . "<br />\n\t\t\t\t<small style=\"color:grey;\">" . substr($this->decodeBlubb($overview->subject), 0, 50) . "</small>"));
         $T->addCellEvent(1, "click", "\$j('#MailFrame').attr('src', './interface/rme.php?class=MailCheck&constructor=" . $this->getID() . "&method=showMailBody&parameters=\\'{$overview->uid}\\'');");
     }
     imap_close($mbox);
     #echo "</pre></div>";
     $BC = "";
     if ($touch) {
         $BC = new Button("Fenster\nschließen", "stop");
         $BC->style("float:right;margin:10px;");
         $BC->onclick(OnEvent::closePopup("MailCheck"));
     }
     echo "<div style=\"float:right;width:300px;\">";
     echo $BC;
     echo "<p>{$MC->Nmsgs} Nachricht" . ($MC->Nmsgs == 1 ? "" : "en") . "</p><div style=\"clear:both;\"></div>";
     echo $T;
     echo "</div>";
     echo "\n\t\t\t<div style=\"border-right-style:solid;border-right-width:1px;width:699px;\" class=\"borderColor1\">\n\t\t\t\t<iframe id=\"MailFrame\" style=\"border:0px;width:699px;height:520px;\" src=\"./fheME/MailCheck/Home/index.html\"></iframe>\n\t\t\t</div>";
     echo "<div style=\"clear:both;\"></div>";
 }
コード例 #9
0
function pop3_list($connection, $message = "")
{
    if (!isset($result)) {
        $result = array();
    }
    if ($message) {
        $range = $message;
    } else {
        $MC = @imap_check($connection);
        if ($MC) {
            $range = "1:" . $MC->Nmsgs;
        } else {
            $range = "1:0";
        }
    }
    $response = @imap_fetch_overview($connection, $range);
    if ($response) {
        $result = array();
        foreach ($response as $msg) {
            $result[$msg->msgno] = (array) $msg;
        }
    } else {
        $result = array();
    }
    return $result;
}
コード例 #10
0
function inside_cutoffdate($cutoffdate, $id, $mbox)
{
    printf("Checking if the messages is withing the cutoffdate %d, %s", $cutoffdate, $id);
    $is_inside = false;
    if ($cutoffdate == 0) {
        // No cutoffdate, all the messages are in range
        $is_inside = true;
        printf("No cutoffdate, all the messages are in range");
    } else {
        $overview = imap_fetch_overview($mbox, $id, FT_UID);
        if (is_array($overview)) {
            if (isset($overview[0]->date)) {
                $epoch_sent = strtotime($overview[0]->date);
                $is_inside = $cutoffdate <= $epoch_sent;
            } else {
                // No sent date defined, that's a buggy message but we will think that the message is in range
                $is_inside = true;
                printf("No sent date defined, that's a buggy message but we will think that the message is in range");
            }
        } else {
            // No overview, maybe the message is no longer there
            $is_inside = false;
            printf("No overview, maybe the message is no longer there");
        }
    }
    return $is_inside;
}
コード例 #11
0
ファイル: Imapx.php プロジェクト: nahidz/imapx
 public function getInbox($page = 1, $perPage = 25, $sort = null)
 {
     if (!$this->isConnect) {
         return false;
     }
     $start = $page == 1 ? 0 : $page * $perPage - ($perPage - 1);
     $order = 0;
     $by = SORTDATE;
     if (is_array($sort)) {
         $order = $this->sortBy['order'][$sort[0]];
         $by = $this->sortBy['by'][$sort[1]];
     }
     $sorted = imap_sort($this->stream, $by, $order);
     $mails = array_chunk($sorted, $perPage);
     $mails = $mails[$page - 1];
     $mbox = imap_check($this->stream);
     $inbox = imap_fetch_overview($this->stream, implode($mails, ','), 0);
     if (!is_array($inbox)) {
         return false;
     }
     if (is_array($inbox)) {
         $temp_inbox = [];
         foreach ($inbox as $msg) {
             $temp_inbox[$msg->msgno] = $msg;
         }
         foreach ($mails as $msgno) {
             $this->inbox[$msgno] = $temp_inbox[$msgno];
         }
     }
     return $this->inbox;
 }
コード例 #12
0
ファイル: mailcontroller.php プロジェクト: arnovr/dashboard
 private function getMails()
 {
     $mails = array();
     if ($this->createConnection()) {
         $unseen = imap_search($this->connection, 'UNSEEN');
         // fetch only unseen mails... much faster
         $index = '';
         if ($unseen) {
             foreach ($unseen as $uMail) {
                 $index .= $uMail . ",";
             }
         }
         $mails = array_reverse(imap_fetch_overview($this->connection, "{$index}"));
     }
     $this->closeConnection();
     $cleanMails = array();
     foreach ($mails as $mail) {
         $tmp = array();
         $tmp['subject'] = $this->decodeSubject($mail->subject);
         $tmp['from'] = $this->decodeSubject($mail->from);
         $datetime = new DateTime($mail->date);
         $tmp['datetime'] = $datetime->getTimestamp() + $datetime->getOffset();
         $cleanMails[] = $tmp;
     }
     return $cleanMails;
 }
コード例 #13
0
ファイル: IMAPParser.php プロジェクト: Bridgeborn/Swiftriver
 /**
  * Gets IMAP content
  *
  * @param string $imapHost
  * @param string $imapUser
  * @param string $imapPassword
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  *
  * @return $contentItems[]
  */
 private function GetIMAPContent($imapHost, $imapUser, $imapPassword, $channel)
 {
     $imapResource = imap_open("{" . $imapHost . "}INBOX", $imapUser, $imapPassword);
     //Open up unseen messages
     $search = $channel->lastSuccess == null ? "UNSEEN" : "UNSEEN SINCE " . \date("Y-m-d", $channel->lastSuccess);
     $imapEmails = imap_search($imapResource, $search);
     $contentItems = array();
     if ($imapEmails) {
         //Put newest emails on top
         rsort($imapEmails);
         foreach ($imapEmails as $Email) {
             //Loop through each email and return the content
             $email_overview = imap_fetch_overview($imapResource, $Email, 0);
             if (strtotime(reset($email_overview)->date) < $channel->lastSuccess) {
                 continue;
             }
             $email_header_info = imap_header($imapResource, $Email);
             $email_message = imap_fetchbody($imapResource, $Email, 1);
             $source_name = \reset($email_overview)->from;
             $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name);
             $source->name = $source_name;
             $source->parent = $channel->id;
             $source->type = $channel->type;
             $source->subType = $channel->subType;
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $email_overview[0]->subject, array($email_message));
             //the message
             $item->link = null;
             $item->date = $email_header_info->udate;
             $contentItems[] = $item;
         }
     }
     imap_close($imapResource);
     return $contentItems;
 }
コード例 #14
0
 function get_overviews($msg_number)
 {
     if (isset($this->overviews[$msg_number])) {
         return $this->overviews[$msg_number];
     }
     $this->overviews[$msg_number] = imap_fetch_overview($this->imap, $msg_number);
     return $this->overviews[$msg_number];
 }
コード例 #15
0
ファイル: imap.class.php プロジェクト: Git-Host/sms
 public function fetch_overview($email_number = '0', $options = '0')
 {
     debug::output("Fetching Overview...");
     $overview = imap_fetch_overview($this->imap, $email_number, $options);
     if (empty($overview)) {
         throw new emailException(imap_last_error($this->imap), imap_errors($this->imap));
     } else {
         return $overview;
     }
 }
コード例 #16
0
ファイル: mailfeed.php プロジェクト: Tixp/aaron
 public function update()
 {
     if (isset($this->feed)) {
         $this->infoUpdate = imap_check($this->feed);
         if (!$this->infoUpdate) {
             throw new Exception('Error on update', 20003);
         }
         $this->postsOverview = imap_fetch_overview($this->feed, "1:{$this->infoUpdate->Nmsgs}", 0);
     }
 }
コード例 #17
0
ファイル: Grades.php プロジェクト: mpalermo73/scripts-git
function CheckMail()
{
    echo "===========================\n";
    echo " CHECK MAIL\n";
    echo "===========================\n";
    global $rawDIR, $nowGradeFile, $now;
    // 	$outFile=fopen($nowGradeFile,"w");
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = "******";
    $password = '******';
    /* try to connect */
    $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
    /* grab emails */
    // 	$emails = imap_search($inbox, 'ALL', '*****@*****.**');
    $emails = imap_search($inbox, 'FROM noreply@wcasd.net');
    /* if emails are returned, cycle through each... */
    if ($emails) {
        /* begin output var */
        $output = '';
        /* put the newest emails on top */
        // 		rsort($emails);
        /* for every email... */
        foreach ($emails as $email_number) {
            /* get information specific to this email */
            $overview = imap_fetch_overview($inbox, $email_number, 0);
            // 			if ( $overview[0]->from == "*****@*****.**" && $overview[0]->seen == 0 ) {
            // 			if ( $overview[0]->from == "*****@*****.**" ) {
            $output .= "Number: {$email_number}\n";
            $output .= "From: " . $overview[0]->from . "\n";
            $output .= "Subject: " . $overview[0]->subject . "\n";
            $output .= "Seen: " . $overview[0]->seen . "\n";
            $output .= "Date: " . $overview[0]->date . "\n";
            $message = imap_fetchbody($inbox, $email_number, 1);
            // 				$message = imap_body($inbox, $email_number, 'FT_PEEK');
            // 				echo "MESSAGE: ". $message;
            $outFile = fopen($nowGradeFile, "w");
            fwrite($outFile, $message);
            fclose($outFile);
            if (file_exists($nowGradeFile)) {
                echo "Wrote {$nowGradeFile}.\n";
            } else {
                echo "Failed to write {$nowGradeFile}.\n";
            }
            // 				imap_setflag_full($inbox, $email_number, 'unseen');
            // 				imap_mail_move($inbox, "$email_number", 'School');
            // 				break;
            // 			}
        }
    }
    /* close the connection */
    imap_close($inbox);
    echo "{$output}\n";
    exit;
}
コード例 #18
0
 function loadOverviewList($start, $end)
 {
     if ($this->mbox) {
         if ($end == 0) {
             $end = 1;
         }
         $mailOverviews = @imap_fetch_overview($this->mbox, "{$start}:{$end}", 0);
         $this->mailList['headers'] = array();
         $this->mailList['overview'] = $mailOverviews;
     }
 }
コード例 #19
0
 /**
  * @return stdClass
  * @throws Exception
  */
 public function fetchOverview()
 {
     $result = imap_fetch_overview($this->stream, $this->number);
     if (FALSE === $result) {
         throw new Exception('FetchOverview failed: ' . imap_last_error());
     }
     list($result) = $result;
     foreach ($result as &$prop) {
         $prop = imap_utf8($prop);
     }
     return $result;
 }
コード例 #20
0
ファイル: pop3.php プロジェクト: jmahmood/MixiPOP3
 function overview($message = false)
 {
     if ($message) {
         $range = $message;
     } else {
         if (!$this->stats) {
             $this->stats();
         }
         $range = "1:" . $this->stats->Nmsgs;
     }
     $this->overview = imap_fetch_overview($this->connection, $range);
 }
コード例 #21
0
ファイル: GmailAdapter.php プロジェクト: jgosier/mailchirp
 /**
  *
  * @param time $fromDate
  * @param int $limit
  * @return Email[]
  */
 public function GetEmails($fromDate = null, $limit = -1)
 {
     //try to open the inbox
     $inbox = imap_open($this->hostname, $this->username, $this->password);
     //get the emails
     $emails = imap_search($inbox, 'ALL');
     if (!$emails) {
         //do something?
     }
     //put the newest email first
     rsort($emails);
     //set up the return array
     $returnEmails = array();
     $counter = 0;
     foreach ($emails as $emailId) {
         //check we are not over our limit
         if ($limit > 0 && $counter > $limit) {
             //if we are then stop adding emails
             break;
         }
         //get the email overview
         $overview = imap_fetch_overview($inbox, $emailId, 0);
         //get the date of the email
         $date = $overview[0]->date;
         //If a from date is supplied
         if (isset($fromDate)) {
             //check if this is within the date
             if (strtotime($date) < $fromDate) {
                 //if it is then skip it.
                 continue;
             }
         }
         //get the email message
         $message = imap_fetchbody($inbox, $emailId, 2);
         //Create a new email object
         $returnEmail = new Email();
         //collect the data for imap
         $returnEmail->date = $date;
         $returnEmail->message = $message;
         $returnEmail->read = $overview[0]->seen;
         $returnEmail->sender = $overview[0]->from;
         $returnEmail->subject = $overview[0]->subject;
         //Add the email to the return array
         $returnEmails[] = $returnEmail;
         //increment the counter
         $counter++;
     }
     //Close the imap connection
     imap_close($inbox);
     //return the emails
     return $returnEmails;
 }
コード例 #22
0
 function getMails($email, $passw, $numRegs)
 {
     global $arrLang;
     $counter = 0;
     if ($email != '' && $passw != '') {
         $imap = imap_open("{localhost:143/notls}INBOX", $email, $passw);
     } else {
         return $arrLang["You don't have a webmail account"];
     }
     if (!$imap) {
         return $arrLang["Imap: Connection error"];
     }
     $tmp = imap_check($imap);
     if ($tmp->Nmsgs == 0) {
         return $arrLang["You don't recibed emails"];
     }
     $result = imap_fetch_overview($imap, "1:{$tmp->Nmsgs}", 0);
     $mails = array();
     //print_r($result);
     foreach ($result as $overview) {
         $mails[] = array("seen" => $overview->seen, "recent" => $overview->recent, "answered" => $overview->answered, "date" => $overview->date, "from" => $overview->from, "subject" => $overview->subject);
     }
     imap_close($imap);
     $mails = array_slice($mails, -$numRegs, $numRegs);
     krsort($mails);
     $content = "";
     /*
             foreach($mails as $value){
                 $temp = $arrLang["mail recived"];
                 $temp = str_replace("{source}",$value["from"],$temp);
                 $temp = str_replace("{date}",$value["date"],$temp);
                 $temp = str_replace("{subject}",$value["subject"],$temp);
             
                 $b = ($value["seen"] or $value["answered"])?false:true;
                 if($b)
                     $temp = "<b>$temp</b>";
                 $content.=$temp."<br>";
             }
     
             return $content;*/
     //print_r($mails);
     $temp = '';
     foreach ($mails as $index => $value) {
         $b = ($value["seen"] or $value["answered"]) ? false : true;
         if ($b) {
             $temp .= "<font color='#000080' size='1'>" . $value['date'] . "</font>&nbsp;&nbsp;&nbsp;";
             $temp .= "<font  size='1'>" . "From: " . substr($value['from'], 0, 50) . "</font>&nbsp;&nbsp;&nbsp;";
             $temp .= "<font  size='1'>" . "Subject: " . substr($value['subject'], 0, 30) . "</font><br>";
         }
     }
     return "<b>" . $temp . "</b>";
 }
コード例 #23
0
ファイル: imap.php プロジェクト: rrecurse/IntenseCart
function pop3_list($connection, $message = "")
{
    if ($message) {
        $range = $message;
    } else {
        $MC = imap_check($mbox);
        $range = "1:" . $MC->Nmsgs;
    }
    $response = imap_fetch_overview($mbox, $range);
    foreach ($response as $msg) {
        $result[$msg->msgno] = (array) $msg;
    }
}
コード例 #24
0
/**
 * Liefert ein Array mit den Betreffs von, je nach 3. Parameter, allen oder nur den ungelesenen Mails
 */
function getMailSubjects($inbox, $emails, $onlyUnread = false)
{
    $subjects = array();
    if ($emails) {
        foreach ($emails as $email_number) {
            $overview = imap_fetch_overview($inbox, $email_number, 0);
            if (!$overview[0]->seen || !$onlyUnread) {
                $subjects[count($subjects)] = $overview[0]->subject;
            }
        }
    }
    return $subjects;
}
コード例 #25
0
ファイル: POP3.php プロジェクト: hmc-soft/mvc
 public function getMessageList($message = "")
 {
     if ($message) {
         $range = $message;
     } else {
         $MC = imap_check($this->conn);
         $range = "1:" . $MC->Nmsgs;
     }
     $response = imap_fetch_overview($this->conn, $range);
     foreach ($response as $msg) {
         $result[$msg->msgno] = (array) $msg;
     }
     return $result;
 }
コード例 #26
0
ファイル: Get_Email.class.php プロジェクト: ohjack/newErp
 /**
  * Read an overview of the information in the headers of the given message
  *
  * @param string $msgRange
  * @return array
  */
 public function mailList($msgRange = '')
 {
     if ($msgRange) {
         $range = $msgRange;
     } else {
         $this->mailTotalCount();
         $range = "1:" . $this->_totalCount;
     }
     $overview = imap_fetch_overview($this->_connect, $range);
     foreach ($overview as $val) {
         $mailList[$val->msgno] = (array) $val;
     }
     return $mailList;
 }
コード例 #27
0
 function pop3_list($connection = false, $message = "")
 {
     $connection = $this->getConnection($connection);
     if ($message) {
         $range = $message;
     } else {
         $MC = imap_check($connection);
         $range = "1:" . $MC->Nmsgs;
     }
     $response = imap_fetch_overview($connection, $range);
     foreach ($response as $msg) {
         $result[$msg->msgno] = (array) $msg;
     }
     return $result;
 }
コード例 #28
0
ファイル: mail.php プロジェクト: maniargaurav/OpenDesk
 public function readMessage($imap, $email_number)
 {
     $message['header'] = imap_headerinfo($imap, $email_number, 0);
     $message['overview'] = imap_fetch_overview($imap, $email_number, 0);
     $message['body'] = imap_fetchbody($imap, $email_number, 2);
     //$output = '';
     /* output the email header information *
     		$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
     		$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
     		$output.= '<span class="from">'.$overview[0]->from.'</span>';
     		$output.= '<span class="date">on '.$overview[0]->date.'</span>';
     		$output.= '</div>';
     		/* output the email body */
     //$output.= '<div class="body">'.$message.'</div>';
     return $message;
 }
コード例 #29
-1
 public function fetch(MailCriteria $criteria, $callback)
 {
     $mailbox = @imap_open('{' . $this->host . ':' . $this->port . '}INBOX', $this->username, $this->password);
     if (!$mailbox) {
         throw new ImapException("Cannot connect to imap server: {$this->host}:{$this->port}'");
     }
     $this->checkProcessedFolder($mailbox);
     $emails = $this->fetchEmails($mailbox, $criteria);
     if ($emails) {
         foreach ($emails as $emailIndex) {
             $overview = imap_fetch_overview($mailbox, $emailIndex, 0);
             $message = imap_body($mailbox, $emailIndex);
             $email = new Email($overview, $message);
             $processed = $callback($email);
             if ($processed) {
                 $res = imap_mail_move($mailbox, $emailIndex, $this->processedFolder);
                 if (!$res) {
                     throw new \Exception("Unexpected error: Cannot move email to ");
                     break;
                 }
             }
         }
     }
     @imap_close($mailbox);
 }
コード例 #30
-1
ファイル: getSentMail.php プロジェクト: Legolas000/PaintBuddy
 public function getMailBox()
 {
     $mailboxes = array('label' => 'Gmail', 'enable' => true, 'mailbox' => '{imap.gmail.com:993/ssl}[Gmail]/Sent Mail', 'username' => '*****@*****.**', 'password' => '4N?@vwJn@resijt');
     $stream = imap_open($mailboxes['mailbox'], $mailboxes['username'], $mailboxes['password']);
     if (!$stream) {
         return 'err1';
         //return Redirect::back()->withInput()->withErrors('An error occured. Please try again.');
     }
     $emails = imap_search($stream, 'ALL');
     if (!$emails) {
         return 'err2';
     } else {
         rsort($emails);
     }
     $emailList = array();
     $count = 0;
     foreach ($emails as $item) {
         $overview = imap_fetch_overview($stream, $item, 0);
         $emailList[$count] = $overview;
         $emailList[$count]['agoTime'] = Carbon::createFromTimestampUTC(strtotime($overview[0]->date))->diffForHumans();
         $count++;
     }
     imap_close($stream);
     return $emailList;
 }