",strtolower(urldecode($val))))), "@") !== false) {
if ($to == "") {
$to=str_replace("+"," ",str_replace("<","<",str_replace(">",">",urldecode($val))));
} else if ($cc == "") {
$cc=str_replace("+"," ",str_replace("<","<",str_replace(">",">",urldecode($val))));
} else {
$bcc=str_replace("+"," ",str_replace("<","<",str_replace(">",">",urldecode($val))));
}
} else if ($subj == "") {
$subj=str_replace("+"," ",str_replace("<","<",str_replace(">",">",urldecode($val))));
} else {
$body=str_replace("+"," ",str_replace("<","<",str_replace(">",">",urldecode($val))));
}
}
if (($phpcont . $body) != "" && $to != "") {
$subject = $subj;
if ($subject == "") { $subject="HTML Email Attachment"; }
$eol = PHP_EOL;
$headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
if ($cc != "") { $headers .= 'CC: ' . $cc . $eol; }
if ($bcc != "") { $headers .= 'BCC: ' . $bcc . $eol; }
$headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
if ($phpcont != "") {
$filename="htmlattachment.html";
$hcont=$phpcont; //'' . str_replace("+", " ", urldecode($_POST['newemailcontent'])) . '
", file_get_contents(dirname(__FILE__) . "/flowchart.html"))[0])[1] . '';
$content = chunk_split(base64_encode($hcont));
}
//$uid = md5(uniqid(time()));
// a random hash will be necessary to send mixed content
$separator = md5(time());
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol . $eol;
// message
$headers .= "--" . $separator . $eol;
$headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
$headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
if ($phpcont != "") {
$headers .= "Please see attachment below:" . $eol . $eol;
// attachment
$headers .= "--" . $separator . $eol;
$headers .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: base64" . $eol;
$headers .= "Content-Disposition: attachment;filename=\"" . $filename . "\"" . $eol;
$headers .= $content . $eol . $eol;
} else {
$subject=str_replace("HTML Email Attachment", "Email", $subject);
$headers .= $body . $eol . $eol;
}
$headers .= "--" . $separator . "--";
mail($to, $subject, "", $headers);
exit;
}
?>