Page 1 of 1

Content-type: text/html when sending HTML email

Posted: Sun Dec 14, 2003 12:02 pm
by larrytech
Hi,

I have been trying to solve aproblem when sending HTML email, whereby everything works until I add "Content-type: text/html" to the headers.

The following code works:

Code: Select all

mail("Sender Name <sender@email.com>", "$subject", "Yes!! ", "From: $personname<$personemail>\n" . "MIME-Version: 1.0\n")
But this doesn't:

Code: Select all

mail("Sender Name <sender@email.com>", "$subject", "Yes!! ", "From: $personname<$personemail>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html\r\n")
Does anybody have any ideas? I would be most grateful - this has been puzzling me for hours.

Regards,
Lawrence

Posted: Sun Dec 14, 2003 1:33 pm
by DuFF
You could try:

Code: Select all

mail("Sender Name <sender@email.com>", "$subject", "Yes!! ", "From: $personname<$personemail>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1\r\n")
Thats what PHP.net has for sending an email with HTML. More info here.

Posted: Sun Dec 14, 2003 3:42 pm
by larrytech
still no luck with that. I am trying other examples mentioned on the link. thanks!

Posted: Sun Dec 14, 2003 4:32 pm
by delorian
I can't tell but is I think you shouldn't use carriage return \r while sending headers. Programs like Outlook and The Bat doesn't like those marks in headers very well.

Posted: Mon Dec 15, 2003 1:30 am
by larrytech
thanks i will bear that in mind. still no luck with the sending though :(

Posted: Mon Dec 15, 2003 1:35 am
by microthick
These are the headers I send in my html emails:

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$from_name." <".$from_address.">\r\n";
$headers .= "Reply-To: ".$from_name." <".$from_address.">\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";

No problems for me.

Posted: Mon Dec 15, 2003 1:59 am
by larrytech
This works:

Code: Select all

$headers = "From: ".$personname." <".$personemail.">\n"; 
$headers .= "MIME-Version: 1.0\n";
As soon as I add any more lines from your example it stops working.

This is really weird because I have other xcripts like it that do work.....