PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




imap_fetchstructure

Name

imap_fetchstructure — Read the structure of an individual message

Synopsis

object imap_fetchstructure(connection, message[, flags]);
int connection: IMAP connection ID
int message: Message number
int flags (optional): Optional flags

Returns

Object containingg message structure information: FALSE on error

Description

imap_fetchstructure() returns a large amount of information about a single message. It returns an object of message properties including:

bytes Number of bytes
encoding Body transfer encoding
lines Number of lines
parts Array of objects describing each message part
type Primary body type
ifdescription True of there is a description string
description Content description string
ifdisposition True if there is a disposition string
disposition Disposition string
ifdparameters True if the disposition parameters array exists
dparameters Disposition parameter array
ifid True if there is an identification string
id Identification string
ifparameters True if the MIME parameters array exists
parameters MIME parameters array
ifsubtype True if there is a subtype string
subtype MIME subtype


In addition to the above list, the parameters property contains an array of attribute/value pairs. The parts property is an array with each element in the array an object containing the same properties as the top level object, except that the properties apply to each part. This can be a little difficult to comprehend but examining the output of this function can lead to a greater understanding.

Version

Since versions 3.0 and 4.0

See also

See also: imap_fetch_overview

Example

Example 602. Dump message structure

<?php
$imap = imap_open("{localhost}INBOX","graeme","inferno");

// delibertely choose a message with an attachment
$message = 7;

// duimp out every property of the message
echo "<pre>\n\n";
print_r(imap_fetchstructure($imap, $message));
echo "\n\n</pre>";

imap_close($imap);
?>

Example 603. File attachment information

<?php
$imap = imap_open("{localhost}INBOX","graeme","inferno");

// delibertely choose a message with an attachment
$message = 7;

$info = imap_fetchstructure($imap, $message);

// find out how may parts the object has
$numparts = count($info->parts);

// find if if multipart message
if ($numparts > 1) {

   echo "More then one part<BR>";
   
   foreach ($info->parts as $part) {

      if ($part->disposition == "INLINE") {
         // inline message. Show number of lines
      
         printf("Inline message has %s lines<BR>", $part->lines);
      
      } elseif ($part->disposition == "ATTACHMENT") {
         // an attachment
      
         echo "Attachment found!";
         // print out the file name
         echo "Filename: ", $part->dparameters[0]->value;
         
      }
      
   }
   
} else {
   // only one part so get some useful info
   echo "Only one part";
}

imap_close($imap);
?>

Output
More then one part
Inline message has 9 lines
Attachment found!Filename: sound1.wav



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.