本文整理汇总了PHP中imap_fetch_overview函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_fetch_overview函数的具体用法?PHP imap_fetch_overview怎么用?PHP imap_fetch_overview使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_fetch_overview函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromImap
/**
* 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: fetch
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: getdata
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: inbox
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 "hotelpartners@goibibo.com" 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: listNew
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: GetIMAPContent
/**
* 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: getImportSets
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: GetIMAPContent
/**
* 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;
}
示例9: inside_cutoffdate
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;
}
示例10: check
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¶meters=\\'{$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>";
}
示例11: pop3_list
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;
}
示例12: getInbox
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;
}
示例13: getMails
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;
}
示例14: fetch
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);
}
示例15: get_overviews
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];
}