How to pull attachments from an email

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
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

How to pull attachments from an email

Post by jasongr »

Hi,

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.

regards
Jason
Post Reply