At 11:11 31-1-2003, you wrote:
Maybe it helps to see how an attachment is send, then you can try to reverse the process to read in attachments.hi allI'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.
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!');
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php