Strange, I thought section numbers worked differently. So then, assuming that an e-mail has a single embedded message, I would want section 2 for mail_fetch_header and section 2.1 for mail_fetch_body?
If an email consists solely of a single embedded message, it would be section 1 instead of section 2. Presumably, if you are using section 2, you have an email with a primary text content and an embedded message as an attachment, e.g.
MULTIPART/MIXED
TEXT/PLAIN "primary text content"
MESSAGE/RFC822 "embedded message"
In that case, then the following is true:
mail_fetch_body() returns the entire body part section 1 => primary text content section 2 => entire embedded message section 2.1 => first MIME part of embedded message section 2.2 => second MIME part of embedded message etc.
mail_fetch_header() returns the header of messages only null section => top level header section 2 => header of embedded message
mail_fetch_text() returns the text of messages only null section => top level text section 2 => embedded message text
Note that you can not call mail_fetch_header() or mail_fetch() text on section 1, nor can you call it on sections 2.1 or 2.2 unless those are also MESSAGE/RFC822 parts.
Is it starting to make sense yet?
The learning curve for how section numbers work *is* steep. The good news is that, when you finally understand the theory of section numbers, it'll be light a light bulb turning on in your head and then you can't imagine how it could be any other way.
I thrashed through all of this when I developed it, and went through several different theories before I finally ended up with this one.
If you are familiar with IMAP (RFC 3501), c-client section numbers are similar to IMAP section numbers, only in c-client they are always numeric.
mail_fetch_body() => <section> mail_fetch_header() => [<section>.]HEADER mail_fetch_text() => [<section>.]TEXT mail_fetch_mime() => <section>.MIME
In other words, mail_fetch_header() of section 2 is IMAP section 2.HEADER and mail_fetch_text() of section 2 is IMAP section 2.TEXT ...
-- Mark --
http://staff.washington.edu/mrc Science does not emerge from voting, party politics, or public debate. Si vis pacem, para bellum.