'.$eol;
$headers .= 'Reply-To: <'.$fromaddress.'>'.$eol;
$headers .= 'Return-Path: <'.$fromaddress.'>'.$eol; // these two to set reply address
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
$msg = "";
// # Setup for text OR html
// $msg .= "--".$mime_boundary.$eol;
// $msg .= "Content-Type: multipart/alternative; boundary=\"".$mime_boundary."\"".$eol;
# Text Version
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
$msg .= $eol.strip_tags(str_replace("
", "\n", $body)).$eol.$eol;
// $msg .= $eol."--".$mime_boundary.$eol.$eol;
/*
# HTML Version
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
$msg .= $eol.$html.$eol.$eol;
*/
if ($attachments != "")
{
$f_contents=chunk_split(base64_encode($attachments)); //Encode The Data For Transition using base64_encode();
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$file_type."; name=\"".$file_name."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $eol.$f_contents.$eol;
}
if ($contents2 != "")
{
$f_contents2=chunk_split(base64_encode($contents2)); //Encode The Data For Transition using base64_encode();
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$filetype2."; name=\"".$fileupload2."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$fileupload2."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $eol.$f_contents2.$eol;
}
if ($contents3 != "")
{
$f_contents3=chunk_split(base64_encode($contents3)); //Encode The Data For Transition using base64_encode();
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$filetype3."; name=\"".$fileupload3."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$fileupload3."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $eol.$f_contents3.$eol;
}
if ($contents4 != "")
{
$f_contents4=chunk_split(base64_encode($contents4)); //Encode The Data For Transition using base64_encode();
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$filetype4."; name=\"".$fileupload4."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$fileupload4."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $eol.$f_contents4.$eol;
}
if ($contents5 != "")
{
$f_contents5=chunk_split(base64_encode($contents5)); //Encode The Data For Transition using base64_encode();
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$filetype5."; name=\"".$fileupload5."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$fileupload5."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $eol.$f_contents5.$eol;
}
if ($contents6 != "")
{
$f_contents6=chunk_split(base64_encode($contents6)); //Encode The Data For Transition using base64_encode();
# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$filetype6."; name=\"".$fileupload6."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$fileupload6."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $eol.$f_contents6.$eol;
}
# Finished
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection.
// echo($msg);
// exit();
# SEND THE EMAIL
// echo($headers . $msg);
//echo($fromaddress . "-". $emailaddress);
ini_set($fromaddress,$emailaddress); // the INI lines are to force the From Address to be used !
mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore($fromaddress);
// echo "mail send";
}
?>