$val) {
if ($key != "access") $msg .= $key." : ".$val."\n\n";
}
$header='';
if (isset($_POST["email"])) $header .= 'From:'.$_POST['email']."\n";
if (count($_FILES)>0) {
$boundary = strtoupper(md5(uniqid(time())));
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$boundary\n\n";
$header .= "This is a multi-part message in MIME format.\n\n";
$header .= "--$boundary\n";
$header .= "Content-Type: text/plain\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$msg\n";
$msg='';
foreach ($_FILES as $filefield => $file) if (is_uploaded_file($file['tmp_name'])) {
$content=chunk_split(base64_encode(fread(fopen($file['tmp_name'],"r"),filesize($file['tmp_name']))));
$header .= "--$boundary\n";
$header .= "Content-Type: ".$file['type']."; name=\"".$file['name']."\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"".$file['name']."\"\n\n";
$header .= "$content\n";
}
$header .= "--$boundary--";
}
mail($recipient, $subject, $msg, $header);
?>