PHP imap download attachment

Unten ich bin die Schleife durch E-Mails mit Hilfe der PHP-imap-Bibliotheken.
Es funktioniert, aber ich bin stecken geblieben auf speichern Anhänge aus der Nachricht.

<?php

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '[email protected]';
$password = 'somepassword';

/* try to connect */
$imap_connection = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

/* grab emails */
$emails = imap_search($imap_connection,'ALL');

/* if emails are returned, cycle through each... */
if($emails) {

    /* begin output var */
    $output = '';

    /* put the newest emails on top */
    rsort($emails);

    /* for every email... */
    foreach($emails as $email_number) {

        $structure = imap_fetchstructure($imap_connection,$email_number);
        if(isset($structure->parts) && count($structure->parts)){

            for($i = 0; $i < count($structure->parts); $i++){   


                if(!empty($structure->parts[$i]->bytes)){

                    if(!empty($ifdparameters)){
                        echo "File: ----".$structure->parts[$i]->dparameters[0]->value; 
                                            //returns: testMeOut.jpg

                    }
                }


            } //eof $i loop


        } //eof $structure->parts 


          } //eof foreach $emails

} //eof if($emails)

?>

Ich versuche zu verstehen, wie so speichern Sie einen Anhang in ein Verzeichnis auf meinem server.
Ich weiß: $structure- > parts[$i]->dparameters[0]->Wert; ist die Rücksendung Sie den Namen der Anlage.

Ich bin sicher, es gibt etwas, was ich tun müssen, um mit imap_fetchbody(), aber ich bin absolut verwirrt, Lesen Sie die tutorials, online-und php-Website.

Kann jemand sehen, mein fehlen die letzten paar Schritte zum speichern eines Anhangs aus $message?

InformationsquelleAutor coffeemonitor | 2012-09-28

Schreibe einen Kommentar