I need to write a script that will connect to a mailbox, and look for emails that have attachments.
Once I find such an email, the script needs to copy all the attachments of specific types (jpeg for example)
to a local file on my web server.

I have playing with the imap_* functions in the IMAP extension and found that I probably need to use
the imap_fetchstructure function in order to get info on the attachments in an email.

My problem is that there are many different ways to have attachments in emails.
Attachments can be embedded or not and there are different MIME types to worry about.

I was wonder if anyone knows of a package that provides a wrapper around the basic IMAP extension
which will make it easy for me to "pull" the attachments and will work with the most common MIME types.