note 45408 added to function.imap-fetchbody
| From: | salesatnocwizarddotcom at osu1 dot php dot net | Date: | Mon, 06 Sep 2004 00:59:07 +0000 |
| Subject: | note 45408 added to function.imap-fetchbody | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76080@lists.php.net to get a copy of this message | ||
I'm adding this for those of you like me who are scouring the web looking for code to break
down a message. These two functions will break down a multi-part and non multi-part message and
return the contents of the message in the array $message. It doesn't do attachments. This
assumes you've already opened the mailbox and pass it VIA the $mbox.
function retrieve_message($mbox, $messageid)
{
$message = array();
$header = imap_header($mbox, $messageid);
$structure = imap_fetchstructure($mbox, $messageid);
$message['subject'] = $header->subject;
$message['fromaddress'] = $header->fromaddress;
$message['toaddress'] = $header->toaddress;
$message['ccaddress'] = $header->ccaddress;
$message['date'] = $header->date;
if (check_type($structure))
{
$message['body'] = imap_fetchbody($mbox,$messageid,"1"); ## GET THE BODY OF
MULTI-PART MESSAGE
if(!$message['body']) {$message['body'] = '[NO TEXT ENTERED INTO THE
MESSAGE]\n\n';}
}
else
{
$message['body'] = imap_body($mbox, $messageid);
if(!$message['body']) {$message['body'] = '[NO TEXT ENTERED INTO THE
MESSAGE]\n\n';}
}
return $message;
}
function check_type($structure) ## CHECK THE TYPE
{
if($structure->type == 1)
{
return(true); ## YES THIS IS A MULTI-PART MESSAGE
}
else
{
return(false); ## NO THIS IS NOT A MULTI-PART MESSAGE
}
}
----
Manual Page -- http://www.php.net/manual/en/function.imap-fetchbody.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45408
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45408&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45408&report=yes
Search -- http://master.php.net/manage/user-notes.php