Re: reading attachmentsl

From: Date: Fri, 31 Jan 2003 13:03:52 +0000
Subject: Re: reading attachmentsl
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-133761@lists.php.net to get a copy of this message
At 11:11 31-1-2003, you wrote:
hi all
    I'm writing a mail client and I got problem with attachments. I have no
idea how to read and save attachments. Mayby someone already did something like that a can help me with some advice or giving me link to some resourses. Maybe it helps to see how an attachment is send, then you can try to reverse the process to read in attachments.
assume that $filedata holds the data you want to attach the encoding can done in many ways, so read the headers carefully //prepare mail body $filedata = chunk_split(base64_encode($filedata)); $type = "application/octet-stream"; $encoding = "base64";
    mt_srand((double)microtime()*1000000);
    $boundary = '--b'.md5(uniqid(mt_rand())) . getmypid();    //so the boundary line can be quite diverse
    $mailbody = "From: PHP backup script by Arakrys\n"
                        ."MIME-Version: 1.0\n"
                        ."Content-Type: multipart/mixed; "
                        ."boundary=\"$boundary\"\n\n"
                        ."This is a MIME encoded message. \n\n"
                        ."--$boundary\n"
                        ."Content-Type: text/plain";
    //if ($this->charset != "")     $mailbody .= "; charset=$this->charset";
    $mailbody .="\n"
                        ."Content-Transfer-Encoding: 8bit\n\n"
                        .$message . "\n\n\n--$boundary";
       $data =     "Content-Type: $type"."; name = \"$filename\""
                ."\n" ."Content-Transfer-Encoding: $encoding"
                ."\n\n$filedata\n";
$mailbody .= "\n$data\n--$boundary"
                        ."--\n";
//send mail mail($mailto, $MYSQL_DB.' database backup '.date("d M Y H:i"), ' ', $mailbody) or die ('Could not send email!'); }

« previous php.general (#133761) next »