Parsing MIME messages using imap_fetchbody

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Parsing MIME messages using imap_fetchbody

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Post Reply