Attach zip to php email script

cca

Perch
Hi, hope someone can hep i'm trying to write a script that emails a zip as an attachment.
I'm on windows server & have tried every script on google, heres one i'm trying with no luck.

heres the script:

//signup2.html

<form action="myscript.php" method="post">
Enter Your E-Mail Address: <input type="text" name="email" size="30"><br>
<input type="submit" value="Submit">


//myscript.php

<?php

$myredirect = "http://mydomain.com/testing/att/signup2.html";

$myname = "me";
$mymail = "[email protected]";

$subject = "Attachment sample";

$message = "Hey! Boy, have I got a file for you.

-me";

$myfile = "advsearch.zip";
$fp = fopen($myfile,"r");
$contents = fread($fp,filesize($myfile));
fclose($fp);

$myimage = base64_encode($contents);

$headers = "From: $myname <$mymail>\nReply-To: <$mymail>\nReturn-Path: <$mymail>\nX-Mailer: PHP\n";

$headers .= "MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"myboundary\";
Content-Transfer-Encoding: 7bit\n";

$headers .= "--myboundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit\n\n";

$headers .= $message."\n";

$headers .= "--myboundary
Content-Type: application/zip; name=$myfile;
Content-Transfer-Encoding: base64
Content-Disposition: attachment

$myimage
--myboundary--";

if ($email != "") { mail($email,$subject,$message ,$headers); }
header("Location:$myredirect"); die();

?>
 
Back
Top