note 95308 modified in function.imap-headers by danbrown

From: Date: Sun, 27 Dec 2009 01:47:05 +0000
Subject: note 95308 modified in function.imap-headers by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164339@lists.php.net to get a copy of this message
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); ?> --was-- Some example of how to use it: <?php $imap = imap_open("{mail.yourserver.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); ?> http://php.net/manual/en/function.imap-headers.php

« previous php.notes (#164339) next »