Re: [PHP] Handling Incoming Email Attachments
[email protected] (Aschwin Wesselius)
| Newsgroups | php.general |
|---|---|
| Message-ID | <[email protected]> |
Nirmal Jayasinghe wrote: > hello all, > > I'm trying to figure out a way to manipulate incoming email attachments with > PHP. There'll be a special email address to which the emails with the > attachments would be sent, with a number specified in the subject line. What > I need to do is to grab the attachment (a photo), rename it with the number > specified in the subject line, and move it onto a specific folder on the Web > server [which will be running LAMP]. > > I couldn't find any online material describing how to manipulate incoming > mail attachments. Can someone give an idea? Hi, For handling e-mail in all their sorts (believe me, it is hell), I found the PECL mailparse the best solution. It can find the attachments and their MIME-types in a snap. And all the headers are separated too. You only have to wrap functions around it to do what you want to do. Be sure to validate the attachments and do not rely on the MIME-type only. People can spoof that kind of files. -- Aschwin Wesselius /'What you would like to be done to you, do that to the other....'/