php mail() problem

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

Post Reply
Php Freek
Forum Newbie
Posts: 10
Joined: Sat Nov 03, 2007 12:06 am

php mail() problem

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php mail() problem

Post by Christopher »

Have you read the PHP manual for the mail() function? There is an example for HTML email.
(#10850)
Php Freek
Forum Newbie
Posts: 10
Joined: Sat Nov 03, 2007 12:06 am

Re: php mail() problem

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php mail() problem

Post by Christopher »

I think it should be "\r\n". I don't know why PHP5 would want only "\n"???
(#10850)
Post Reply