Some example of how to use it:
<?php
$imap = imap_open("{mail.example.com:143}INBOX", "username", "password");
$message_count = imap_num_msg($imap);
for ($i = 1; $i <= $message_count; ++$i) {
$header = imap_header($imap, $i);
$body = trim(substr(imap_body($imap, $i), 0, 100));
$prettydate = date("jS F Y", $header->udate);
if (isset($header->from[0]->personal)) {
$personal = $header->from[0]->personal;
} else {
$personal = $header->from[0]->mailbox;
}
$email = "$personal <{$header->from[0]->mailbox}@{$header->from[0]->host}>";
echo "On $prettydate, $email said \"$body\".\n";
}
imap_close($imap);
?>
imap_headers
(PHP 4, PHP 5)
imap_headers — Returns headers for all messages in a mailbox
Description
array imap_headers
( resource $imap_stream
)
Returns headers for all messages in a mailbox.
Return Values
Returns an array of string formatted with header info. One element per mail message.
imap_headers
jose dot yapur at usmp dot pe
25-Dec-2009 09:28
25-Dec-2009 09:28
mmuoio at gmail dot com
12-Oct-2009 05:39
12-Oct-2009 05:39
This function will not return a full subject line if it is longer than 25 characters. I found this out after trying to search each header and move the email to a different folder depending on what the subject was (searching for year and project number).
