imap_fetchbody uses a complicated algorithm of assigning part numbers to each message part. So complicated I've personally spent almost a year, off and on, studying it. It doesn't behave the same between different message structures. However, it does behave predictably and consistently, if that makes sense. I have written a whole PEAR package using it and the rest of the c-client extension as a backend. So that said, you are welcomed and encouraged to use my Mail_IMAP PEAR package!
You can find the latest version, source code, extended documentation, etc at my website:
http://www.smilingsouls.net/index.ph...ail_IMAP/index
As for explaining how imap_fetchbody works, you've found the right person to ask, but I don't have time at the moment to go into detail on it, this being an immensely complicated topic. The short answer is, imap_fetchbody is closely related to imap_fetchstructure, so that'd be the place to start. The premise is certain message parts are supposed to be ignored in certain situations. So to get a handle on it, have a look at the source of Mail_IMAP. If you have more questions after looking over Mail_IMAP, I would be happy to answer them.
HTH!
Regards,
Rich
--
[
http://www.smilingsouls.net]
[
http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail