15.8 Getting the Size of a Message


15.8 Getting the Size of a Message

You want to get the size of a particular message.

Technique

Use the imap_fetchstructure() function:

 <?php $structure = imap_fetchstructure($mh, $msg_num); $message_size = $structure->bytes; $message_size_in_kb = $message_size/1024; ?> 

Comments

The imap_fetchstructure() function fetches the structure as a psuedo-object of an individual message specified by $msg_num . One of the attributes of that psuedo-object is the bytes attribute, which returns the message size in bytes. Most people work with kilobytes, so to convert from bytes to kilobytes, we need to divide by the number of bytes in a kilobyte, or 1024. For more information about imap_fetchstructure() and its other attributes, see the documentation for the function.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net