PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
larrytech
Forum Commoner
Posts: 35 Joined: Thu Jun 06, 2002 8:27 am
Post
by larrytech » Sun Dec 14, 2003 12:02 pm
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
DuFF
Forum Contributor
Posts: 495 Joined: Tue Jun 24, 2003 7:49 pm
Location: USA
Post
by DuFF » Sun Dec 14, 2003 1:33 pm
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 .
larrytech
Forum Commoner
Posts: 35 Joined: Thu Jun 06, 2002 8:27 am
Post
by larrytech » Sun Dec 14, 2003 3:42 pm
still no luck with that. I am trying other examples mentioned on the link. thanks!
delorian
Forum Contributor
Posts: 223 Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland
Post
by delorian » Sun Dec 14, 2003 4:32 pm
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.
larrytech
Forum Commoner
Posts: 35 Joined: Thu Jun 06, 2002 8:27 am
Post
by larrytech » Mon Dec 15, 2003 1:30 am
thanks i will bear that in mind. still no luck with the sending though
microthick
Forum Regular
Posts: 543 Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC
Post
by microthick » Mon Dec 15, 2003 1:35 am
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.
larrytech
Forum Commoner
Posts: 35 Joined: Thu Jun 06, 2002 8:27 am
Post
by larrytech » Mon Dec 15, 2003 1:59 am
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.....