Page 1 of 1

Parsing MIME messages using imap_fetchbody

Posted: Tue Jul 31, 2007 11:20 am
by impulse()
I'm getting a little confused with the 3rd parameter of imap_fetchbody and what I should be specifying if I want to retrieve just the e-mail message with no headers or anything else that comes with the email. And also what I should specify if I want to retrieve just the attachment part (IE - .zip files or .pdf files).

What complicates this more is that these e-mails are RFC822 attachments of another e-mail. There doesn't seem a way to precisely define that I want certain areas from an e-mail and there's very little documentation anywhere and the documentation that is around the internet doesn't explain how to parse required parts of RFC822 attachments that may also contain attachments.

Posted: Tue Jul 31, 2007 12:12 pm
by Chris Corbyn
The IMAP functions are very good at parsing RFC2822 messages. They basically don't cover all bases for possible ways to compose a messages. In your case I think you may be out of luck due to the depth of nesting in the MIME data.

AFAIK, PEAR has a MIME class which may do a better job.