Assuming $struct = imap_fetchstructure($x,$y);
It is important to note that if a message has NO attachements, $struct->parts is an empty array, and $struct->bytes has a value. If a message as ANY attachements, $struct->bytes ALWAYS = 0. To get the size of the primary body, you have to call structure->part[0]->bytes. To get the size of the whole message, either strlen(imap_body) or add up the ->bytes of all the parts.
Another interesting note:
When there is body text and no attachements:
count($struct->parts) = 0
When there is body text and 1 attachement:
count($struct->parts) = 2
These imap functions could really use better documentation. Like giving the meathods for the dparameter and parameter classes...