I have been trying to get mail to send html emails however it seems that whenever i change the header from
$message .= "Content-type:text/plain; charset=iso-8859-1
"; to
$message .= "Content-type:text/html; charset=iso-8859-1
";
the email does not arrive.When using text/plain, i receive the email however the html is not rendered, in other words i received the code rather than formatted html. Changing to text/html, the email is not received at all. I have tried using UTF-8 but can not seem to solve it after hours of searching. Any help would be appreciated.
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $emessage) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: ".$from_name." <".$from_mail.">
";
$header .= "Reply-To: ".$replyto."
";
$header .= "MIME-Version: 1.0
";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"
";
$message = "--".$uid."
";
$message .= "Content-type:text/plain; charset=iso-8859-1
";
//$message .= "Content-Type: text/html; charset=\"UTF-8\""."
";
//$message .= "Content-type:text/html; charset=UTF-8
";
$message .= "Content-Transfer-Encoding: 7bit
";
$message .= $emessage."
";
$message .= "--".$uid."
";
$message .= "Content-Type: application/octet-stream; name=\"".$filename."\"
";
$message .= "Content-Transfer-Encoding: base64
";
$message .= "Content-Disposition: attachment; filename=\"".$filename."\"
";
$message .= $content."
";
$message .= "--".$uid."--";
return mail($mailto, $subject, $message, $header);
}