Using to read email server + retrieve new email + saving attachment

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello,  use found here (
browse/file/3925.html) to connect to my email server and to retrieve
new emails. The function also look at attachment and save the file on
a folder. Problem, the image files copied on the folder on my web
server, have size of 0k.

Here is the piece of code where I save the attachment (image) in the

        // Give image a unique filename
        $rand = md5(uniqid(rand(), 1));
        $new_name = $rand.".jpg";

        // Save image!
        $image = fopen( $new_name, "wb" );
        fwrite( $image, base64_decode( $file ) );
        fclose( $image );

Anyone who used know what's wrong with this?

Thanks for your help.


Re: Using to read email server + retrieve new email + saving attachment


on 01/27/2008 02:13 AM said the following:
Quoted text here. Click to load it

I have never used that class. You may need to ask the author directly.

I used this other POP3 client class which comes with an useful stream
that lets you open messages in your mailbox with the fopen() as if they
were regular files using filenames like this:


If you want to extract any attachements or any other types of message
parts, you can pass message stream file name to this other MIME parser
class, which parses the messages and can save message parts to files in
a given directory:

Take a look at the parse_message.php example of the POP3 class.


Manuel Lemos

PHP professionals looking for PHP jobs

PHP Classes - Free ready to use OOP components written in PHP

Site Timeline