Carriage return problem inside a email message.

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
ajarantes
Forum Newbie
Posts: 3
Joined: Tue Sep 30, 2008 12:42 pm

Carriage return problem inside a email message.

Post by ajarantes »

The e-mail I'm sending insists in not recognize the line-feed/carriage-return "\n\r". I send it to Gmail, Yahoo, Hotmail and the text always arrive as one single paragraph. The "\n\r" don't show up but also don't create new lines or paragraphs.

Only when I send to one of my own e-mail addresses and open with "squirrelMail" is that it opens correctly. But when I download the same e-mail to my computer and open with Thunderbird, it goes back to one only paragraph.

Do you have any idea what else I can try? Thanks.

Here is the code:

Code: Select all

[color=#0000BF]$to = $mail;
$subject = $subj;
$message = "Dear $name,\r\r\n\n" .
           "This e-mail was sent to you to confirm your registration with KIMIMI.\r\r\n\n" .
           "You have 24 hours to proceed with this confirmation or your registration will be lost." .
           "To finalize the process and start using all the wonderful features of KIMIMI, " . 
           "clik on the link below or, if you do not allow HTML in the e-mails " .
           "you receive, copy and paste the link to your browser address area \r\r\n\n" .
           "http://www.kimimi.net/confreg.php?id=$confstring\r\r\n\n" .
           "If you have any problems, please contact us.\r\r\n\n" . 
           "Welcome to KIMIMI\r\nThe Kimimi Team\r\nwww.kimimi.net";
$headers = "From: info@kimimi.net\r\n" ;
$headers .= "To: $email <".$email.">\r\n" ;
$headers .= "Reply-To: info@kimimi.net\r\n" ;
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
$mail = mail($to, $subject, $message, $headers);[/color]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Carriage return problem inside a email message.

Post by RobertGonzalez »

try using \r\n\r\n instead of \r\r\n\n. Or try using just one of them.

What platform is your server?
ajarantes
Forum Newbie
Posts: 3
Joined: Tue Sep 30, 2008 12:42 pm

Re: Carriage return problem inside a email message.

Post by ajarantes »

Everah,

Thank you for answering so fast...

I tried all options, with \r\n\r\n, \r\r, and \n\n and still no success.

the server in my hosting company is a Linux/Apache.

Cheers,
Alex
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Carriage return problem inside a email message.

Post by RobertGonzalez »

Have you tried using heredoc syntax for the text? Or perhaps string literals with concatenated variables? It would certainly remove the need for using ascii characters in the body.

Or maybe even a template parser?
ajarantes
Forum Newbie
Posts: 3
Joined: Tue Sep 30, 2008 12:42 pm

Re: Carriage return problem inside a email message.

Post by ajarantes »

Everah and everyone else.

I just found the problem with the help of another expert...

The problem was the Content-type.

Once I changed it to "text/plain" the problem was gone.

I hope it help others.

Thank you very much!!!!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Carriage return problem inside a email message.

Post by RobertGonzalez »

Sorry about that. It was right in your code and I didn't even see it.

Glad you got it sorted though.
amera
Forum Newbie
Posts: 9
Joined: Fri Sep 19, 2008 6:49 am

Re: Carriage return problem inside a email message.

Post by amera »

Thank you for your kindness
I will to learn more about this topic .
Post Reply