15.8 Getting the Size of a Message
TechniqueUse the imap_fetchstructure() function: <?php $structure = imap_fetchstructure($mh, $msg_num); $message_size = $structure->bytes; $message_size_in_kb = $message_size/1024; ?> CommentsThe 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. |