• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imap_fetchheader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了imap_fetchheader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: fetch

	/**
	 * Recupera o conteúdo de uma mensagem
	 * @param	MailContext $context Contexto da conexão
	 * @param	Message $message
	 * @return	Message A própria mensagem
	 * @throws	MailStateException Caso o estado do objeto não implemente abertura
	 * @throws	MailException Caso não seja possível recuperar o conteúdo da mensagem
	 */
	public function fetch( MailContext $context , Message $message ) {
		$msgNum = imap_msgno( ImapState::$resource , $message->getUID() );

		$structure = imap_fetchstructure( ImapState::$resource , $msgNum );
		$overview = (array) current( imap_fetch_overview( ImapState::$resource , $msgNum ) );

		$message->setHeaders( imap_fetchheader( ImapState::$resource , $msgNum ) );
		$message->setOverview( $overview );

		if ( isset( $structure->parts ) && count( $structure->parts ) ) {
			foreach ( $structure->parts as $key => $part ) {
				$this->fetchContent( $message , $part->subtype , $msgNum , $key + 1 );
			}
		} else {
			$this->fetchContent( $message , $structure->subtype , $msgNum , 1 );
		}
	}
开发者ID:netojoaobatista,项目名称:phpmail,代码行数:25,代码来源:ImapOpenedState.php


示例3: listHeaderMessages

 /**
  * Lista o cabeçalho das 100 primeiras mensagens armazenadas
  *
  * @param string $textSearch
  * @return \ZendT_Mail_Service_HeaderMessage[]
  */
 public function listHeaderMessages($textSearch = 'ALL')
 {
     $itens = array();
     $messages = $this->getMailsInfo($this->searchMailbox($textSearch));
     $limitMessage = 100;
     $iMessage = 0;
     foreach ($messages as $message) {
         if ($iMessage == $limitMessage) {
             break;
         }
         $head = imap_rfc822_parse_headers(imap_fetchheader($this->getImapStream(), $message->uid, FT_UID));
         $item = new ZendT_Mail_HeaderMessage();
         $item->id = $head->message_id;
         $item->dateTime = date('Y-m-d H:i:s', isset($head->date) ? strtotime($head->date) : time());
         $item->subject = $this->decodeMimeStr($head->subject, $this->serverEncoding);
         $item->from = strtolower($head->from[0]->mailbox . '@' . $head->from[0]->host);
         $toStrings = array();
         foreach ($head->to as $to) {
             if (!empty($to->mailbox) && !empty($to->host)) {
                 $toEmail = strtolower($to->mailbox . '@' . $to->host);
                 $toName = isset($to->personal) ? $this->decodeMimeStr($to->personal, $this->serverEncoding) : null;
                 $toStrings[] = $toName ? "{$toName} <{$toEmail}>" : $toEmail;
             }
         }
         $item->to = implode(', ', $toStrings);
         $itens[] = $item;
         $iMessage++;
     }
     return $itens;
 }
开发者ID:rtsantos,项目名称:mais,代码行数:36,代码来源:Imap.php


示例4: retrieve_message

function retrieve_message($auth_user, $accountid, $messageid, $fullheaders)
{
    $message = array();
    if (!($auth_user && $messageid && $accountid)) {
        return false;
    }
    $imap = open_mailbox($auth_user, $accountid);
    if (!$imap) {
        return false;
    }
    $header = imap_header($imap, $messageid);
    if (!$header) {
        return false;
    }
    $message['body'] = imap_body($imap, $messageid);
    if (!$message['body']) {
        $message['body'] = "[This message has no body]\n\n\n\n\n\n";
    }
    if ($fullheaders) {
        $message['fullheaders'] = imap_fetchheader($imap, $messageid);
    } else {
        $message['fullheaders'] = '';
    }
    $message['subject'] = $header->subject;
    $message['fromaddress'] = $header->fromaddress;
    $message['toaddress'] = $header->toaddress;
    $message['ccaddress'] = $header->ccaddress;
    $message['date'] = $header->date;
    // note we can get more detailed information by using from and to
    // rather than fromaddress and toaddress, but these are easier
    imap_close($imap);
    return $message;
}
开发者ID:andersonbporto,项目名称:programacao_internet_2015_1,代码行数:33,代码来源:mail_fns.php


示例5: get_message

 function get_message($uid)
 {
     $raw_header = imap_fetchheader($this->stream, $uid, FT_UID);
     $raw_body = imap_body($this->stream, $uid, FT_UID);
     $message = new Email_Parser($raw_header . $raw_body);
     return $message;
 }
开发者ID:optimumweb,项目名称:php-email-reader-parser,代码行数:7,代码来源:email_reader.php


示例6: get_message

	function get_message($msg)
	{
		$header = imap_fetchheader($this->_connection, $msg);
		echo "<h1>header {$msg}:</h1><br>".$header;
		$message = imap_body($this->_connection, $msg);
		echo "<h1>message {$msg}:</h1><br>".$message;
		return $header.$message;
	}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:8,代码来源:pop3_socket.class.php


示例7: fetch_raw_mail

 function fetch_raw_mail($stream, $msg_num, $flags = 0)
 {
     $flags |= FT_PREFETCHTEXT;
     // do we force use of msg UID's
     if ($this->force_msg_uids == True && !($flags & FT_UID)) {
         $flags |= FT_UID;
     }
     return imap_fetchheader($stream, $msg_num, $flags);
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:9,代码来源:class.mail_dcom_pop3.inc.php


示例8: getImapHeaderInfo

 /**
  * @param $mailId
  * @return object
  */
 public function getImapHeaderInfo($mailId)
 {
     $imapHeader = imap_fetchheader($this->getImapStream(), $mailId, FT_UID);
     $parsed = array();
     $blocks = preg_split('/\\n\\n/', $imapHeader);
     $matches = array();
     foreach ($blocks as $i => $block) {
         $parsed[$i] = array();
         $lines = preg_split('/\\n(([\\w.-]+)\\: *((.*\\n\\s+.+)+|(.*(?:\\n))|(.*))?)/', $block, -1, PREG_SPLIT_DELIM_CAPTURE);
         foreach ($lines as $line) {
             if (preg_match('/^\\n?([\\w.-]+)\\: *((.*\\n\\s+.+)+|(.*(?:\\n))|(.*))?$/', $line, $matches)) {
                 $parsed[$i][$matches[1]] = preg_replace('/\\n +/', ' ', trim($matches[2]));
             }
         }
     }
     return $parsed;
 }
开发者ID:pnoreck,项目名称:mailscanner,代码行数:21,代码来源:Mailbox.php


示例9: headerMsg

 /**
  * Cabesera de mensage
  * 
  * @param  int $numMsg 
  * @return array
  */
 public function headerMsg($numMsg, $uid = false)
 {
     //$numMsg es el uid y no el numero de secuencia
     if ($uid) {
         $numMsg = imap_msgno($this->connect, $numMsg);
     }
     $header = explode("\n", imap_fetchheader($this->connect, $numMsg));
     if (is_array($header) && count($header)) {
         $head = array();
         foreach ($header as $line) {
             // separate name and value
             eregi("^([^:]*): (.*)", $line, $arg);
             $head[$arg[1]] = $arg[2];
         }
     }
     return $head;
 }
开发者ID:ncrousset,项目名称:get-mail-imap,代码行数:23,代码来源:Imap.php


示例10: fetch

 static function fetch($options)
 {
     if ($mbox = imap_open(sprintf('{%1$s:%2$s/%3$s}INBOX', $options['server'], $options['port'], implode('/', $options['settings'])), $options['user'], $options['pass'])) {
         $ret = array();
         if (($messages = imap_num_msg($mbox)) > 0) {
             for ($message = 1; $message < $messages + 1; $message++) {
                 $eml = imap_fetchheader($mbox, $message) . imap_body($mbox, $message);
                 $data = array('Task' => array());
                 $email_data = LilTasksParseEmail::__parseEmailHeader($mbox, $message);
                 $data['Task']['title'] = $email_data['subject'];
                 $data['Task']['happened'] = strftime('%Y-%m-%d', strtotime($email_data['date']));
                 list($sender, $domain) = explode('@', $email_data['from']);
                 if ($sender == 'today') {
                     $data['Task']['deadline'] = strftime('%Y-%m-%d');
                 } else {
                     if ($sender == 'tomorrow') {
                         $data['Task']['deadline'] = strftime('%Y-%m-%d', time() + 24 * 60 * 60);
                     } else {
                         if (in_array(strtolower($sender), array('monday', 'tuesday', 'wednesday', 'thursday', 'saturday', 'sunday'))) {
                             $data['Task']['deadline'] = strftime('%Y-%m-%d', strtotime('next ' . ucfirst($sender)));
                         }
                     }
                 }
                 $hash = sha1($data['Task']['happened'] . '_' . $email_data['subject']);
                 $parts = array();
                 $data['Task']['descript'] = LilTasksParseEmail::__parseEmailBody($mbox, $message, $hash, $parts);
                 file_put_contents(TMP . $hash . '.eml', $eml);
                 $data['Attachment'][0] = array('model' => 'Task', 'filename' => array('name' => $hash . '.eml', 'tmp_name' => TMP . $hash . '.eml'), 'title' => 'SOURCE: ' . $data['Task']['title']);
                 App::uses('Sanitize', 'Utility');
                 foreach ($parts as $part) {
                     if (!empty($part['attachment'])) {
                         $data['Attachment'][] = array('model' => 'Task', 'filename' => array('name' => Sanitize::paranoid($part['attachment']['filename']), 'tmp_name' => $part['attachment']['tmp']), 'title' => $part['attachment']['filename']);
                     }
                 }
                 $ret[$message] = $data;
                 imap_delete($mbox, $message);
             }
         }
         return $ret;
         imap_close($mbox, CL_EXPUNGE);
     } else {
         var_dump(imap_errors());
     }
 }
开发者ID:malamalca,项目名称:lil-tasks,代码行数:44,代码来源:LilTasksParseEmail.php


示例11: email_msg_headers

function email_msg_headers($mbox, $uid)
{
    $raw_header = $mbox && $uid ? @imap_fetchheader($mbox, $uid, FT_UID) : '';
    $raw_header = str_replace("\r", '', $raw_header);
    $ret = array();
    $h = split("\n", $raw_header);
    if (count($h)) {
        foreach ($h as $line) {
            if (preg_match("/^[a-zA-Z]/", $line)) {
                $key = substr($line, 0, strpos($line, ':'));
                $value = substr($line, strpos($line, ':') + 1);
                $last_entry = strtolower($key);
                $ret[$last_entry] = trim($value);
            } else {
                $ret[$last_entry] .= ' ' . trim($line);
            }
        }
    }
    return $ret;
}
开发者ID:nextgensh,项目名称:friendica,代码行数:20,代码来源:email.php


示例12: getHeaders

 function getHeaders($mid)
 {
     if (!$this->marubox) {
         return false;
     }
     $mail_header = @imap_fetchheader($this->marubox, $mid);
     if ($mail_header == false) {
         return false;
     }
     $mail_header = imap_rfc822_parse_headers($mail_header);
     $sender = isset($mail_header->from[0]) ? $mail_header->from[0] : '';
     $sender_replyto = isset($mail_header->reply_to[0]) ? $mail_header->reply_to[0] : '';
     if (strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster') {
         $newvalue['personal'] = $this->email_Decode($sender->personal);
         $newvalue['sender_personal'] = $this->email_Decode($sender_replyto->personal);
         $newvalue['subject'] = $this->email_Decode($mail_header->subject);
         $newvalue['toaddress'] = isset($mail_header->toaddress) ? $this->email_Decode($mail_header->toaddress) : '';
         $mail_header = (array) $mail_header;
         $sender = (array) $sender;
         $mail_details = array('feid' => imap_uid($this->marubox, $mid), 'from' => strtolower($sender['mailbox']) . '@' . $sender['host'], 'from_name' => $newvalue['personal'], 'to_other' => strtolower($sender_replyto->mailbox) . '@' . $sender_replyto->host, 'toname_other' => $newvalue['sender_personal'], 'subjects' => $newvalue['subject'], 'to' => $newvalue['toaddress'], 'time' => strtotime($mail_header['Date']));
     }
     return $mail_details;
 }
开发者ID:knowsee,项目名称:uoke_framework,代码行数:23,代码来源:mail.class.php


示例13: imap_get_url

function imap_get_url($u)
{
    if (!($c = imap_open_url($u))) {
        return FALSE;
    }
    extract(parse_url($u));
    extract(imap_parse_path($path));
    if ($mailbox) {
        if ($uid) {
            $msgno = imap_msgno($c, $uid);
            $o = imap_fetchstructure($c, $msgno);
        } else {
            $o = array();
            $n = imap_num_msg($c);
            while ($i++ < $n) {
                $o[] = imap_fetchheader($c, $i);
            }
        }
    } else {
        $o = imap_list($c, '{}', '*');
    }
    return $o;
}
开发者ID:nbtscommunity,项目名称:phpfnlib,代码行数:23,代码来源:imap.php


示例14: parseHeader

 private function parseHeader()
 {
     $header = imap_fetchheader($this->client->connection, $this->uid, FT_UID);
     if ($header) {
         $header = imap_rfc822_parse_headers($header);
     }
     if (property_exists($header, 'subject')) {
         $this->subject = imap_utf8($header->subject);
     }
     if (property_exists($header, 'date')) {
         $this->date = Carbon::parse($header->date);
     }
     if (property_exists($header, 'from')) {
         $this->from = $this->parseAddresses($header->from);
     }
     if (property_exists($header, 'to')) {
         $this->to = $this->parseAddresses($header->to);
     }
     if (property_exists($header, 'cc')) {
         $this->cc = $this->parseAddresses($header->cc);
     }
     if (property_exists($header, 'bcc')) {
         $this->bcc = $this->parseAddresses($header->bcc);
     }
     if (property_exists($header, 'reply_to')) {
         $this->reply_to = $this->parseAddresses($header->reply_to);
     }
     if (property_exists($header, 'sender')) {
         $this->sender = $this->parseAddresses($header->sender);
     }
     if (property_exists($header, 'message_id')) {
         $this->message_id = str_replace(['<', '>'], '', $header->message_id);
     }
     if (property_exists($header, 'Msgno')) {
         $this->message_no = trim($header->Msgno);
     }
 }
开发者ID:zalazdi,项目名称:laravel-imap,代码行数:37,代码来源:Message.php


示例15: ob_start

 ob_start();
 $mbox = @imap_open($_email['server'], $_email['username'], $_email['password']);
 if (!$mbox) {
     ob_end_clean();
     sleep(10);
     continue;
 }
 $processed = 0;
 $msgs = @imap_search($mbox, 'UNSEEN');
 if ($msgs) {
     foreach ($msgs as $msgid) {
         // Crap out here if we've run out of time
         if (time() >= $endtime) {
             break;
         }
         $imap_headers = @imap_fetchheader($mbox, $msgid);
         if (!$imap_headers) {
             break;
         }
         $headers = array();
         foreach (explode("\n", trim($imap_headers)) as $header) {
             if (strlen(trim($header)) == 0 or $header[0] == ' ' or $header[0] == "\t") {
                 continue;
             }
             list($key, $val) = explode(':', trim($header));
             $key = strtolower($key);
             $val = trim($val);
             switch ($key) {
                 case 'x-twitterrecipientscreenname':
                     if ($val != $_twitter['username']) {
                         // Skip to the next message - this one is not for us!
开发者ID:ntulip,项目名称:TwitApps,代码行数:31,代码来源:check_email.php


示例16: mysql_connect

    <body>
        <?php 
mysql_connect('localhost', 'kamas3_emailsc', 'bingo45');
mysql_select_db('kamas3_emailsc');
$user = '[email protected]';
$pass = 'satnam';
$imap_server = "{192.254.214.105:143/imap/notls}INBOX";
// Connect to the pop3 email inbox belonging to $user
// If you need SSL remove the novalidate-cert section
$mbox = imap_open($imap_server, $user, $pass);
$MC = imap_check($mbox);
$sorted_mbox = imap_sort($mbox, SORTDATE, 1);
$totalrows = imap_num_msg($mbox);
$startvalue = 0;
while ($startvalue < $totalrows && $startvalue < 100) {
    $headers = imap_fetchheader($mbox, $sorted_mbox[$startvalue]);
    // echo $headers;
    // echo htmlentities($headers->message_id);
    $subject = array();
    preg_match_all('/^Subject: (.*)/m', $headers, $subject);
    // print $subject[1][0] . "<br />";
    $subject = isset($subject[1][0]) ? $subject[1][0] : (isset($subject[0][0]) ? $subject[0][0] : '');
    if (strpos(strtolower($subject), 'enquiry for you at') !== FALSE) {
        $msg = imap_fetchbody($mbox, $sorted_mbox[$startvalue], 2);
        // echo $msg.'</br>';
        $msg_array = explode('<tr', $msg);
        echo count($msg_array) . " ";
        if (count($msg_array) < 5) {
            $msg_array = explode('<TR', $msg);
            //echo count($msg_array)." ";
        }
开发者ID:sixthlife,项目名称:JustDialtoMySQL,代码行数:31,代码来源:index.php


示例17: _getFormattedMail

 /**
  * get the basic details like sender and reciver with flags like attatchments etc
  *
  * @param int $uid the number of the message
  * @return array empty on error/nothing or array of formatted details
  */
 protected function _getFormattedMail($Model, $uid, $fetchAttachments = false)
 {
     // Translate uid to msg_no. Has no decent fail
     $msg_number = imap_msgno($this->Stream, $uid);
     // A hack to detect if imap_msgno failed, and we're in fact looking at the wrong mail
     if ($uid != ($mailuid = imap_uid($this->Stream, $msg_number))) {
         pr(compact('Mail'));
         return $this->err($Model, 'Mail id mismatch. parameter id: %s vs mail id: %s', $uid, $mailuid);
     }
     // Get Mail with a property: 'date' or fail
     if (!($Mail = imap_headerinfo($this->Stream, $msg_number)) || !property_exists($Mail, 'date')) {
         pr(compact('Mail'));
         return $this->err($Model, 'Unable to find mail date property in Mail corresponding with uid: %s. Something must be wrong', $uid);
     }
     // Get Mail with a property: 'type' or fail
     if (!($flatStructure = $this->_flatStructure($Model, $uid))) {
         return $this->err($Model, 'Unable to find structure type property in Mail corresponding with uid: %s. Something must be wrong', $uid);
     }
     $plain = $this->_fetchFirstByMime($flatStructure, 'text/plain');
     $html = $this->_fetchFirstByMime($flatStructure, 'text/html');
     $return[$Model->alias] = array('id' => $this->_toId($uid), 'message_id' => $Mail->message_id, 'email_number' => $Mail->Msgno, 'to' => $this->_personId($Mail, 'to', 'address'), 'to_name' => $this->_personId($Mail, 'to', 'name'), 'from' => $this->_personId($Mail, 'from', 'address'), 'from_name' => $this->_personId($Mail, 'from', 'name'), 'reply_to' => $this->_personId($Mail, 'reply_to', 'address'), 'reply_to_name' => $this->_personId($Mail, 'reply_to', 'name'), 'sender' => $this->_personId($Mail, 'sender', 'address'), 'sender_name' => $this->_personId($Mail, 'sender', 'name'), 'subject' => htmlspecialchars(@$Mail->subject), 'slug' => Inflector::slug(@$Mail->subject, '-'), 'header' => @imap_fetchheader($this->Stream, $uid, FT_UID), 'body' => $html, 'plainmsg' => $plain ? $plain : $html, 'size' => @$Mail->Size, 'recent' => @$Mail->Recent === 'R' ? 1 : 0, 'seen' => @$Mail->Unseen === 'U' ? 0 : 1, 'flagged' => @$Mail->Flagged === 'F' ? 1 : 0, 'answered' => @$Mail->Answered === 'A' ? 1 : 0, 'draft' => @$Mail->Draft === 'X' ? 1 : 0, 'deleted' => @$Mail->Deleted === 'D' ? 1 : 0, 'thread_count' => $this->_getThreadCount($Mail), 'in_reply_to' => @$Mail->in_reply_to, 'reference' => @$Mail->references, 'new' => (int) @$Mail->in_reply_to, 'created' => date('Y-m-d H:i:s', strtotime($Mail->date)));
     if ($fetchAttachments) {
         $return['Attachment'] = $this->_fetchAttachments($flatStructure, $Model);
     }
     // Auto mark after read
     if (!empty($this->config['auto_mark_as'])) {
         $marks = '\\' . join(' \\', $this->config['auto_mark_as']);
         if (!imap_setflag_full($this->Stream, $uid, $marks, ST_UID)) {
             $this->err($Model, 'Unable to mark email %s as %s', $uid, $marks);
         }
     }
     return $return;
 }
开发者ID:rikdc,项目名称:cakephp-emails-plugin,代码行数:39,代码来源:imap_source.php


示例18: fetchHeader

 public function fetchHeader()
 {
     return imap_fetchheader($this->connection, $this->message_id);
 }
开发者ID:yuju-framework,项目名称:yuju-imap,代码行数:4,代码来源:Mailbox_Message.php


示例19: check_mailbox

 protected function check_mailbox()
 {
     imap_ping($this->conn);
     $count = imap_num_msg($this->conn);
     common_log(LOG_INFO, "Found {$count} messages");
     if ($count > 0) {
         $handler = new IMAPMailHandler();
         for ($i = 1; $i <= $count; $i++) {
             $rawmessage = imap_fetchheader($this->conn, $count, FT_PREFETCHTEXT) . imap_body($this->conn, $i);
             $handler->handle_message($rawmessage);
             imap_delete($this->conn, $i);
         }
         imap_expunge($this->conn);
         common_log(LOG_INFO, "Finished processing messages");
     }
     return $count;
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:17,代码来源:imapmanager.php


示例20: getMail

 /**
  * Get mail data
  *
  * @param $mailId
  * @param bool $markAsSeen
  * @return IncomingMail
  */
 public function getMail($mailId, $markAsSeen = true)
 {
     $head = imap_rfc822_parse_headers(imap_fetchheader($this->getImapStream(), $mailId, FT_UID));
     $mail = new IncomingMail();
     $mail->id = $mailId;
     $mail->date = date('Y-m-d H:i:s', isset($head->date) ? strtotime(preg_replace('/\\(.*?\\)/', '', $head->date)) : time());
     $mail->subject = isset($head->subject) ? $this->decodeMimeStr($head->subject, $this->serverEncoding) : null;
     $mail->fromName = isset($head->from[0]->personal) ? $this->decodeMimeStr($head->from[0]->personal, $this->serverEncoding) : null;
     $mail->fromAddress = strtolower($head->from[0]->mailbox . '@' . $head->from[0]->host);
     if (isset($head->to)) {
         $toStrings = array();
         foreach ($head->to as $to) {
             if (!empty($to->mailbox) && !empty($to->host)) {
                 $toEmail = strtolower($to->mailbox . '@' . $to->host);
                 $toName = isset($to->personal) ? $this->decodeMimeStr($to->personal, $this->serverEncoding) : null;
                 $toStrings[] = $toName ? "{$toName} <{$toEmail}>" : $toEmail;
                 $mail->to[$toEmail] = $toName;
             }
         }
         $mail->toString = implode(', ', $toStrings);
     }
     if (isset($head->cc)) {
         foreach ($head->cc as $cc) {
             $mail->cc[strtolower($cc->mailbox . '@' . $cc->host)] = isset($cc->personal) ? $this->decodeMimeStr($cc->personal, $this->serverEncoding) : null;
         }
     }
     if (isset($head->reply_to)) {
         foreach ($head->reply_to as $replyTo) {
             $mail->replyTo[strtolower($replyTo->mailbox . '@' . $replyTo->host)] = isset($replyTo->personal) ? $this->decodeMimeStr($replyTo->personal, $this->serverEncoding) : null;
         }
     }
     if (isset($head->message_id)) {
         $mail->messageId = $head->message_id;
     }
     $mailStructure = imap_fetchstructure($this->getImapStream(), $mailId, FT_UID);
     if (empty($mailStructure->parts)) {
         $this->initMailPart($mail, $mailStructure, 0, $markAsSeen);
     } else {
         foreach ($mailStructure->parts as $partNum => $partStructure) {
             $this->initMailPart($mail, $partStructure, $partNum + 1, $markAsSeen);
         }
     }
     return $mail;
 }
开发者ID:ladybirdweb,项目名称:momo-email-listener,代码行数:51,代码来源:Mailbox.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imap_fetchstructure函数代码示例发布时间:2022-05-15
下一篇:
PHP imap_fetchbody函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap