Forum Moderators: coopster

Message Too Old, No Replies

sending HTML mail()'s

         

bagheera

3:38 pm on Mar 20, 2004 (gmt 0)

10+ Year Member



Hi,

I have a problem when sending HTML mail (using css). The mails just incluse all the HTML tags...
So can you send both text and HTML so that the server receiving can use the text mail if HTML mail is not supported?

Or is it always best only to use plain text as I understand is advised? - it is the first time Ill use the mail() function.

Thanks

dcrombie

3:48 pm on Mar 20, 2004 (gmt 0)



IMHO plain text is always better - email and WWW are separate channels on the Internet and shouldn't be mixed.

Having said that, to send HTML email you need to look into MIME types and headers.

httpwebwitch

2:10 am on Mar 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This mail wrapper function handles some problems with hotmail and priorities. It sends HTML mail.


<?php
function send_mail($fromname,$fromemail,$toname,$toemail,$message,$subject,$priority){
// check priority
if($priority=="High" ¦ $priority=="high" ¦ $priority=="1" ¦ $priority==1){
$xprior = 1;
$prior = "High";
}elseif($priority=="Normal" ¦ $priority=="Medium" ¦ $priority=="3" ¦ $priority==3){
$xprior = 3;
$prior = "Normal";
}elseif($priority=="Low" ¦ $priority=="low" ¦ $priority=="5" ¦ $priority==5){
$xprior = 5;
$prior = "Low";
}else{
$xprior = 3;
$prior = "Normal";
}

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$fromname." <".$fromemail.">\r\n";
$headers .= "To: ".$toname." <".$toemail.">\r\n";
$headers .= "Reply-To: ".$fromname." <".$fromemail.">\r\n";
$headers .= "X-Priority: ".$xprior."\r\n";
$headers .= "X-MSMail-Priority: ".$prior."\r\n";
$headers .= "X-Mailer: yourdomain.com";

$success = mail("", $subject, $message, $headers);
return $success;
}
?>