Page 1 of 1

php mail() problem

Posted: Fri Feb 15, 2008 6:29 am
by Php Freek
Hi All,

I am facing strange problem right now in my server. I have php 5 installed with all needed rpms in linux server.

I am using the mail() with following code.

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: email@email.com \r\n";
$headers .= "Bcc: email@email.com \r\n";

$message = "test";

mail("email@email.com","email@email.com",$message,$headers);

Now the message comes in html code. In yahoo mail account the mail is going with html tags applied properly but in gmail and other few mail account, it is going without taking any effect and all tags are just showing.

They are coming like

Content-type: text/html; charset=iso-8859-1
From: email@email.com

<font face=Verdana, Arial, Helvetica, sans-serif size=1><b>test<b></font>

in gmail

but in yahoo it is coming properly,

test

Can anyone help me out of this problem?

Mark.

Re: php mail() problem

Posted: Fri Feb 15, 2008 1:01 pm
by Christopher
Have you read the PHP manual for the mail() function? There is an example for HTML email.

Re: php mail() problem

Posted: Fri Feb 15, 2008 11:45 pm
by Php Freek
Hi ,

I removed only '\r' from the code and it started working like a dream. Now this is weired i think.

Why \r was working perfactly in old server and in new dedicated server it was not working??

Is it php 4 and php 5 problem or is it server security problem?

Please let me know for the reason as \r\n combination is in php manual and if it does not work then there must be some big change.

Thanks again.

Re: php mail() problem

Posted: Sat Feb 16, 2008 9:27 am
by Christopher
I think it should be "\r\n". I don't know why PHP5 would want only "\n"???