downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imap_headers> <imap_header
Last updated: Fri, 30 Oct 2009

view this page in

imap_headerinfo

(PHP 4, PHP 5)

imap_headerinfoLiest die Kopfdaten einer Nachricht

Beschreibung

object imap_headerinfo ( resource $imap_stream , int $msg_number [, int $fromlength = 0 [, int $subjectlength = 0 [, string $defaulthost = NULL ]]] )

Liest die Kopfdaten der Nachricht mit der Nummer msg_number und liefert daraus gewonnene Informationen zurück.

Parameter-Liste

imap_stream

Eine von imap_open() zurückgegebene IMAP-Verbindung.

msg_number

Die gewünschte Nachrichtennummer

fromlength

Maximale Anzahl Zeichen für die fetchfrom Eigenschaft (muß größer als Null sein)

subjectlength

Maximale Anzahl Zeichen für die subject Eigenschaft (muß größer als Null sein)

defaulthost

Rückgabewerte

Die Ergebnisse werden in einem Objekt mit folgenden Eigenschaften zurückgegeben:

  • toaddress - Inhalt des "To:" Felds (max. 1024 Zeichen)
  • to - ein Array mit aus den einzelnen Empfängern aus dem "To:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • fromaddress - Inhalt des "From:" Felds (max. 1024 Zeichen)
  • from - ein Array mit aus den einzelnen Empfängern aus dem "From:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • ccaddress - Inhalt des "Cc:" Felds (max. 1024 Zeichen)
  • cc - ein Array mit aus den einzelnen Empfängern aus dem "Cc:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • bccaddress - Inhalt des "Bcc:" Felds (max. 1024 Zeichen)
  • bcc - ein Array mit aus den einzelnen Empfängern aus dem "Bcc:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • reply_toaddress - Inhalt des "Reply-To:" Felds (max. 1024 Zeichen)
  • reply_to - ein Array mit aus den einzelnen Empfängern aus dem "Reply-To:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • senderaddress - Inhalt des "Sender:" Felds (max. 1024 Zeichen)
  • sender - ein Array mit aus den einzelnen Empfängern aus dem "Sender:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • return_pathaddress - Inhalt des "Return-Path:" Felds (max. 1024 Zeichen)
  • return_path - ein Array mit aus den einzelnen Empfängern aus dem "Return-Path:" Feld. Jedes Array-Element hat die Eigenschaften personal, adl, mailbox und host
  • remail -
  • date - Sendedatum der Nachricht laut Kopfdaten
  • Date - enthält die gleichen Daten wie 'date'
  • subject - die Betreffzeile der Nachricht
  • Subject - enthält die gleichen Daten wie 'subject'
  • in_reply_to -
  • message_id -
  • newsgroups -
  • followup_to -
  • references -
  • Recent - R wenn kürzlich eingetroffen und gelesen, N wenn kürzlich eingetroffen und ungelesen, ' ' wenn nicht kürzlich eingetroffen
  • Unseen - U wenn nicht kürzlich eingetroffen UND ungelesen, ' ' wenn gelesen ODER ungelesen und kürzlich eingetroffen.
  • Flagged - F wenn als wichtig markiert, sonst ' '
  • Answered - A wenn beantwortet, sonst' '
  • Deleted - D wenn zum Löschen vorgemerkt, sonst ' '
  • Draft - X wenn als Entwurf markiert, sonst ' '
  • Msgno - die Nachrichtennummer
  • MailDate -
  • Size - Größe der Nachricht in Bytes
  • udate - Sendedatum als Unix-Timestamp
  • fetchfrom - "From:" Zeile limitiert auf fromlength Zeichen characters
  • fetchsubject - "Subject:" Zeile limitiert auf subjectlength Zeichen

Siehe auch



imap_headers> <imap_header
Last updated: Fri, 30 Oct 2009
 
add a note add a note User Contributed Notes
imap_headerinfo
aeolianmeson at exoyiga dot blitzeclipse dot com
17-May-2009 05:56
I typically use UID's to identify messages, and recently discovered that the headers I had been pulling using this function and a message-number didn't match the UID's. Instead of worrying about it, I just began using imap_fetchheader() and imap_ rfc822_ parse_ headers() on its output. The only significant difference I immediately noticed was that there is no "udate" property, so I assigned one with the result of strtotime() on the 'date' property.

Dustin
php at spacefish dot biz
27-Jan-2009 06:57
I had to pass the msgid as array($msgid) instead of an integer. the error "Invalid messageID" is generated if i pass an integer.
ron at NOSPAM dot clicks2hits dot com
06-Nov-2008 01:51
Simple little code for checking gmail using headerinfo

<?php /* Created on: 11/3/2008 By Ron Hickey 6tx.net/gmail_mod
Gmail mod for admin panels or you can edit it and convert html results to XML for personal RSS reader */

// enter gmail username below e.g.--> $m_username = "yourusername";
$m_username = "";

// enter gmail password below e.g.--> $m_password = "yourpword";
$m_password = "";

// enter the number of unread messages you want to display from mailbox or
//enter 0 to display all unread messages e.g.--> $m_acs = 0;
$m_acs = 15;

// How far back in time do you want to search for unread messages - one month = 0 , two weeks = 1, one week = 2, three days = 3,
// one day = 4, six hours = 5 or one hour = 6 e.g.--> $m_t = 6;
$m_t = 2;

//----------->Nothing More to edit below
//open mailbox..........please
$m_mail = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX", $m_username . "@gmail.com", $m_password)

// or throw a freakin error............you pig
or die("ERROR: " . imap_last_error());

// unix time gone by or is it bye.....its certanly not bi.......or is it? ......I dunno fooker
$m_gunixtp = array(2592000, 1209600, 604800, 259200, 86400, 21600, 3600);

// Date to start search
$m_gdmy = date('d-M-Y', time() - $m_gunixtp[$m_t]);

//search mailbox for unread messages since $m_t date
$m_search=imap_search ($m_mail, 'UNSEEN SINCE ' . $m_gdmy . '');

//If mailbox is empty......Display "No New Messages", else........ You got mail....oh joy
if($m_search < 1){
$m_empty = "No New Messages";}
else {

// Order results starting from newest message
rsort($m_search);

//if m_acs > 0 then limit results
if($m_acs > 0){
array_splice($m_search, $m_acs);
}

//loop it
foreach ($m_search as $what_ever) {

//get imap header info for obj thang
$obj_thang = imap_headerinfo($m_mail, $what_ever);

//Then spit it out below.........if you dont swallow
echo "<body bgcolor=D3D3D3><div align=center><br /><font face=Arial size=2 color=#800000>Message ID# " . $what_ever . "</font>

<table bgcolor=#D3D3D3 width=700 border=1 bordercolor=#000000 cellpadding=0 cellspacing=0>
<tr>
<td><table width=100% border=0>
<tr>
<td><table width=100% border=0>
<tr>
<td bgcolor=#F8F8FF><font face=Arial size=2 color=#800000>Date:</font> <font face=Arial size=2 color=#000000>"
. date("F j, Y, g:i a", $obj_thang->udate) . "</font></td>
<td bgcolor=#F8F8FF><font face=Arial size=2 color=#800000>From:</font> <font face=Arial size=2 color=#000000>"
. $obj_thang->fromaddress . "</font></td>
<td bgcolor=#F8F8FF><font face=Arial size=2 color=#800000>To:</font> <font face=Arial size=2 color=#000000>"
. $obj_thang->toaddress . " </font></td>
</tr>
<tr>
</table>
</td>
</tr><tr><td bgcolor=#F8F8FF><font face=Arial size=2 color=#800000>Subject:</font> <font face=Arial size=2 color=#000000>"
. $obj_thang->Subject . "</font></td></tr><tr>
</tr>
</table></td>
</tr>
</table><a href=http://gmail.com target=_blank><font face=Arial size=2 color=#800000>Login to read message</a></font><br /></div></body>"
;

}} echo
"<div align=center><font face=Arial size=4 color=#800000><b>" . $m_empty . "</b></font></div>";
//close mailbox bi by bye
imap_close($m_mail);
?>
scott at fuzzygroup dot com
11-Nov-2002 05:13
If you want to extract values from to, from, or other header elements, they are an object and you need to loop over them i.e.

$header = imap_header($mbox, $message_id);
$from = $header->from;
foreach ($from as $id => $object) {
    $fromname = $object->personal;
    $fromaddress = $object->mailbox . "@" . $object->host;
}

Would give you two variables for the friendly from and the smtp from address

Thanks to www.natrak.net for help with this

imap_headers> <imap_header
Last updated: Fri, 30 Oct 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites