当前位置: 首页>>代码示例>>PHP>>正文


PHP imap_headerinfo函数代码示例

本文整理汇总了PHP中imap_headerinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_headerinfo函数的具体用法?PHP imap_headerinfo怎么用?PHP imap_headerinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imap_headerinfo函数的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;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:35,代码来源:ImapMessage.php

示例2: readEmails

 public function readEmails($sentTo = null, $bodyPart = null)
 {
     $host = '{imap.gmail.com:993/imap/ssl}INBOX';
     $spinner = new Spinner('Could not connect to Imap server.', 60, 10000);
     $inbox = $spinner->assertBecomesTrue(function () use($host) {
         return @imap_open($host, $this->email, $this->password);
     });
     $emails = imap_search($inbox, 'TO ' . ($sentTo ? $sentTo : $this->email));
     if ($emails) {
         $messages = [];
         foreach ($emails as $n) {
             $structure = imap_fetchstructure($inbox, $n);
             if (!$bodyPart) {
                 $part = $this->findPart($structure, function ($part) {
                     return $part->subtype === 'HTML';
                 });
             } elseif (is_callable($bodyPart)) {
                 $part = $this->findPart($structure, $bodyPart);
             } else {
                 $part = $bodyPart;
             }
             $hinfo = imap_headerinfo($inbox, $n);
             $subject = $hinfo->subject;
             $message = ['subject' => $subject, 'body' => imap_fetchbody($inbox, $n, $part)];
             $messages[] = $message;
         }
         return $messages;
     } else {
         return [];
     }
 }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:31,代码来源:GmailReader.php

示例3: getHeader

 /**
  * @return \Ephp\ImapBundle\Entity\Header
  */
 protected function getHeader($mid, $inbox = null)
 {
     if (!$inbox) {
         $inbox = $this->inbox;
     }
     $header = imap_headerinfo($inbox, $mid);
     if (!$header) {
         throw new \Exception('Email not found');
     }
     $out = new \Ephp\ImapBundle\Entity\Header();
     if (isset($header->Subject)) {
         $out->setSubject($header->Subject);
     } elseif (isset($header->subject)) {
         $out->setSubject($header->subject);
     } else {
         $out->setSubject('no subject');
     }
     $out->setSize($header->Size);
     $out->setDate($header->Date);
     $out->setMessageId($header->message_id);
     if (isset($header->to)) {
         $out->setTo($header->to);
     }
     if (isset($header->from)) {
         $out->setFrom($header->from);
     }
     if (isset($header->cc)) {
         $out->setCc($header->cc);
     }
     if (isset($header->bcc)) {
         $out->setBcc($header->bcc);
     }
     return $out;
 }
开发者ID:ephp,项目名称:imap,代码行数:37,代码来源:ImapController.php

示例4: inbox

 function inbox()
 {
     $this->msg_cnt = imap_num_msg($this->conn);
     $in = array();
     for ($i = 1; $i <= 20; $i++) {
         $in[] = array('index' => $i, 'header' => imap_headerinfo($this->conn, $i), 'body' => imap_body($this->conn, $i), 'structure' => imap_fetchstructure($this->conn, $i));
     }
     $this->inbox = $in;
 }
开发者ID:networksoft,项目名称:erp.multinivel,代码行数:9,代码来源:Email_reader.php

示例5: get_messages

 /**
  * Get messages according to a search criteria
  *
  * @param	string	search criteria (RFC2060, sec. 6.4.4). Set to "UNSEEN" by default
  *					NB: Search criteria only affects IMAP mailboxes.
  * @param	string	date format. Set to "Y-m-d H:i:s" by default
  * @return	mixed	array containing messages
  */
 public function get_messages($search_criteria = "UNSEEN", $date_format = "Y-m-d H:i:s")
 {
     //$msgs = imap_num_msg($this->imap_stream);
     $no_of_msgs = imap_num_msg($this->imap_stream);
     $messages = array();
     for ($i = 1; $i <= $no_of_msgs; $i++) {
         $header = imap_headerinfo($this->imap_stream, $i);
         $message_id = $header->message_id;
         $date = date($date_format, $header->udate);
         if (isset($header->from)) {
             $from = $header->from;
         } else {
             $from = FALSE;
         }
         $fromname = "";
         $fromaddress = "";
         $subject = "";
         if ($from != FALSE) {
             foreach ($from as $id => $object) {
                 if (isset($object->personal)) {
                     $fromname = $object->personal;
                 }
                 $fromaddress = $object->mailbox . "@" . $object->host;
                 if ($fromname == "") {
                     // In case from object doesn't have Name
                     $fromname = $fromaddress;
                 }
             }
         }
         if (isset($header->subject)) {
             $subject = $this->_mime_decode($header->subject);
         }
         // Read the message structure
         $structure = imap_fetchstructure($this->imap_stream, $i);
         if (!empty($structure->parts)) {
             for ($j = 0, $k = count($structure->parts); $j < $k; $j++) {
                 $part = $structure->parts[$j];
                 if ($part->subtype == 'PLAIN') {
                     $body = imap_fetchbody($this->imap_stream, $i, $j + 1);
                 }
             }
         } else {
             $body = imap_body($this->imap_stream, $i);
         }
         // Convert quoted-printable strings (RFC2045)
         $body = imap_qprint($body);
         // Convert to valid UTF8
         $body = htmlentities($body);
         $subject = htmlentities($subject);
         array_push($messages, array('message_id' => $message_id, 'date' => $date, 'from' => $fromname, 'email' => $fromaddress, 'subject' => $subject, 'body' => $body));
         // Mark Message As Read
         imap_setflag_full($this->imap_stream, $i, "\\Seen");
     }
     return $messages;
 }
开发者ID:Bridgeborn,项目名称:Ushahidi_Web,代码行数:63,代码来源:Imap.php

示例6: __construct

 public function __construct($Number, &$Mailbox)
 {
     $this->Mailbox =& $Mailbox;
     $Connection =& $this->Mailbox->Connection;
     $Tmp = imap_fetch_overview($Connection, $Number);
     $this->Overview = $Tmp[0];
     $this->Structure = imap_fetchstructure($Connection, $Number);
     $this->HeaderInfo = imap_headerinfo($Connection, $Number);
     $this->MailDateTime = Gdn_Format::ToDateTime($this->HeaderInfo->udate);
     $this->Number = $this->Overview->msgno;
     $this->Uid = $this->Overview->uid;
     $this->RetrieveInfo();
     $this->RetrieveBodyText();
     $this->RetrieveAttachments();
     return $this;
 }
开发者ID:unlight,项目名称:UsefulFunctions,代码行数:16,代码来源:class.imapmailbox.php

示例7: getMail

 /**
  * Gets the mail from the inbox
  * Reads all the messages there, and adds posts based on them. Then it deletes the entire mailbox.
  */
 function getMail()
 {
     $config = Config::current();
     if (time() - 60 * $config->emailblog_minutes >= $config->emailblog_mail_checked) {
         $hostname = '{' . $config->emailblog_server . '}INBOX';
         # this isn't working well on localhost
         $username = $config->emailblog_address;
         $password = $config->emailblog_pass;
         $subjpass = $config->emailblog_subjpass;
         $inbox = imap_open($hostname, $username, $password) or exit("Cannot connect to Gmail: " . imap_last_error());
         $emails = imap_search($inbox, 'SUBJECT "' . $subjpass . '"');
         if ($emails) {
             rsort($emails);
             foreach ($emails as $email_number) {
                 $message = imap_body($inbox, $email_number);
                 $overview = imap_headerinfo($inbox, $email_number);
                 imap_delete($inbox, $email_number);
                 $title = htmlspecialchars($overview->Subject);
                 $title = preg_replace($subjpass, "", $title);
                 $clean = strtolower($title);
                 $body = htmlspecialchars($message);
                 # The subject of the email is used as the post title
                 # the content of the email is used as the body
                 # not sure about compatibility with images or audio feathers
                 Post::add(array("title" => $title, "body" => $message), $clean, Post::check_url($clean), "text");
             }
         }
         # close the connection
         imap_close($inbox, CL_EXPUNGE);
         $config->set("emailblog_mail_checked", time());
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:36,代码来源:emailblog.php

示例8: setStructureFromMail

 /**
  * Open mail from Imap and parse structure
  * @license   http://www.gnu.org/copyleft/gpl.html GPL
  * @author    Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
  * @return string  menssagem
  */
 public function setStructureFromMail($folder, $msgNumber)
 {
     $this->folder = mb_convert_encoding($folder, 'UTF7-IMAP', mb_detect_encoding($folder . 'x', 'UTF-8, ISO-8859-1'));
     $this->msgNumber = $msgNumber;
     $this->username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
     $this->password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
     $this->imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
     $this->imap_port = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
     $this->imap_delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'];
     $this->imap_sentfolder = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] : str_replace("*", "", $this->functions->getLang("Sent"));
     $this->has_cid = false;
     if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes') {
         $this->imap_options = '/tls/novalidate-cert';
     } else {
         $this->imap_options = '/notls/novalidate-cert';
     }
     $this->mbox = @imap_open("{" . $this->imap_server . ":" . $this->imap_port . $this->imap_options . "}" . $this->folder, $this->username, $this->password) or die('Error');
     $header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $this->msgNumber), 80, 255);
     $this->messageId = $header->message_id;
     $rawMessageData = $this->_getRaw();
     $decoder = new Mail_mimeDecode($rawMessageData);
     $this->structure = $decoder->decode($this->decodeConf);
     //TODO: Descartar código após atualização do módulo de segurança da SERPRO
     if ($this->isSignedMenssage()) {
         $this->convertSignedMenssage($rawMessageData);
     }
     //////////////////////////////////////////////////////
     /*
      * Clean memory and close imap connection
      */
     $rawMessageData = null;
     $decoder = null;
     @imap_close($this->mbox);
     //-----------------------------------------//
 }
开发者ID:cjvaz,项目名称:expressomail,代码行数:41,代码来源:class.attachment.inc.php

示例9: readImapStatus

function readImapStatus($config, $savedStatus, $db)
{
    $mbox = imap_open($config["imap_server"], $config["imap_user"], $config["imap_password"]);
    $imapStatus = imap_status($mbox, $config["imap_server"], SA_ALL);
    // Read message IDs of UNSEEN mails
    $unseen = [];
    if ($imapStatus->unseen > 0) {
        $messages = imap_search($mbox, "UNSEEN");
        foreach ($messages as $msgID) {
            $msg = imap_headerinfo($mbox, $msgID);
            $unseen[] = $msg->message_id;
        }
    }
    imap_close($mbox);
    //
    $last_unseen = json_decode($savedStatus->unseen);
    $new_message_found = false;
    foreach ($unseen as $key => $value) {
        // Does 'unseen' contain msgID we haven't seen before?
        if (array_search($value, $last_unseen) === FALSE) {
            $new_message_found = true;
        }
    }
    // Current unseen list doesn't match saved one
    if (count($unseen) != count($last_unseen) || $new_message_found) {
        saveStatusToSqlite($db, "unseen", json_encode($unseen));
    }
    return $new_message_found;
}
开发者ID:McFizh,项目名称:hackster-cc3200-email,代码行数:29,代码来源:common.php

示例10: emailListener

function emailListener()
{
    $connection = establishConnection();
    $dbConn = establishDBConnection();
    $messagestatus = "UNSEEN";
    $emails = imap_search($connection, $messagestatus);
    if ($emails) {
        rsort($emails);
        foreach ($emails as $email_number) {
            // echo "in email loop";
            $header = imap_headerinfo($connection, $email_number);
            $message = imap_fetchbody($connection, $email_number, 1.1);
            if ($message == "") {
                $message = imap_fetchbody($connection, $email_number, 1);
            }
            $emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1));
            if (!detectOOOmessage($header->subject, $message, $emailaddress)) {
                detectBIOmessage($header->subject, $emailaddress);
            }
            imap_delete($connection, 1);
            //this might bug out but should delete the top message that was just parsed
        }
    }
    $dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(NOW(), INTERVAL -1 DAY) limit 1");
    //delete mentors that have been away for more than 24 hours from the away list
}
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:26,代码来源:AutoBackendOutOfTimeShow.php

示例11: imap_get_mail_array

 function imap_get_mail_array()
 {
     for ($i = 1; $i < $this->__imap_count_mail() + 1; $i++) {
         $mailHeader[] = @imap_headerinfo($conn, $i);
     }
     return $mailHeader;
 }
开发者ID:hardikamutech,项目名称:campaign,代码行数:7,代码来源:_imap_helper.php

示例12: get_header

 function get_header($msg_number)
 {
     if (isset($this->header[$msg_number])) {
         return $this->header[$msg_number];
     }
     $this->header[$msg_number] = imap_headerinfo($this->imap, $msg_number);
     return $this->header[$msg_number];
 }
开发者ID:asaquzzaman,项目名称:email-attachment-to-dropbox,代码行数:8,代码来源:attachment-list.php

示例13: get_plain_text_subject

function get_plain_text_subject($mbox, $msgNum, $headers = null)
{
    $headers or $headers = imap_headerinfo($mbox, $msgNum);
    $subjectParts = imap_mime_header_decode($headers->Subject);
    $subject = '';
    foreach ($subjectParts as $p) {
        $subject .= $p->text;
    }
    return trim($subject);
}
开发者ID:rudiedirkx,项目名称:IMAP-reader,代码行数:10,代码来源:test.br-autohelpdesk.php

示例14: getHeader

 private function getHeader()
 {
     if (!isset($this->header)) {
         try {
             $this->header = imap_headerinfo($this->imap_stream, $this->message_index, 800, 800);
         } catch (Exception $e) {
             return false;
         }
     }
     return $this->header;
 }
开发者ID:htmlgraphic,项目名称:HTMLgraphic-MVC,代码行数:11,代码来源:IMAPEmail.class.inc.php

示例15: getMessage

 public function getMessage($msg_id = 1)
 {
     $message = new MailMessage();
     if ($this->getNumMessages() > 0) {
         $header_info = imap_headerinfo($this->box, $msg_id);
         $message->setSubject($header_info->subject);
         $message->setSenderAddress($header_info->from[0]->mailbox . "@" . $header_info->from[0]->host);
         $message->setMessage(imap_fetchbody($this->box, $msg_id, 1));
         $this->addAttachments($message, $msg_id);
         return $message;
     }
 }
开发者ID:vsanth,项目名称:yii-customer-database,代码行数:12,代码来源:mailbox.php


注:本文中的imap_headerinfo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。