Hi there,
I'm trying to create a form that sends an email with a .zip file attached. I'm using the following code I found on the Internet:
The email gets sent and everything but the .zip arrives empty. What I want to know is how do you tell it where to look for the attachment. For example if I change the $file paramter to "C:\\attach_test.zip" it sends the email with an attachment named "C:\\attach_test.zip" instead of looking for it on my C drive.
Thanks.
I'm trying to create a form that sends an email with a .zip file attached. I'm using the following code I found on the Internet:
Code:
<?php
function sendmsg($to, $subject, $text, $from, $file, $type) {
$content = fread(fopen($file,"r"),filesize($file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = basename($file);
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/plain\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";
$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
mail($to, $subject, "", $header);
return true;
}
sendmsg("submit@codeinthewhole.com", "Hi Code in the Whole Webmaster", "Hi Code in the Whole Webmaster!\n\nyou have a great script!", "Tim Bennett", "attach_test.zip", "application/x-zip-compressed");
?>
Thanks.