View Full Version : working with mail (imap)

10-13-2009, 01:10 PM
Hi all!

Does anybody know, how to find a full documentation about how to handle mail attachements with imap? I could find only this article: http://www.linuxscope.net/articles/mailAttachmentsPHP.html

But it doesn't work allways. Here is the message example: http://new1.flyupload.com/files/view/d9TJ6jCWqA8Sghs5meYi Not all pictures are diccovered by the script.

So, does anybody know, where to find more information about mail attachments?

it career
10-14-2009, 01:23 PM
You can also check
www.phpclasses.org/browse/package/2964.html ,etc.

10-14-2009, 01:39 PM
Thank's very much)

I've started to study this problem by making print_r() of $structure->parts. It's really amazing, how it is built. I'm having a great deal of fun.

This link: http://www.linuxscope.net/articles/mailAttachmentsPHP.html doesn't work for "Content-Type: multipart/mixed;" messages.

The point is, u should find in $structure->parts all objects with two atributes, like this:

[0] => stdClass Object
[attribute] => name
[value] => image002.jpg

If such object is found, we have a file attachment and we know the name of the file. But u should do it very carefull, 'cause $structure->parts consists of many different objects and arrays.

Right now I am wondering, how to parse it's body, I'll write here later.

Added 5 minutes later: And here (http://ru.php.net/manual/en/function.imap-fetchbody.php#82766) I found how to fetch it's body. Thank's a lot.