Jump to content

message from mysql field showing \n's and \r's in email


scarhand

Recommended Posts

i am using the php mail() function to send a message from a mysql database (text) field

 

the problem is, if the message has text that goes on new lines, etc. then the \r's and \n's show up in the email

 

<?php

$email_body = $row['details'];

mail("[email protected]", "New Message!", $email_body, "From: [email protected]");

?>

 

the email looks like this:

 

test a reply\r\n\r\n(working on stuff)\r\nblah blah blah

 

the nl2br function does not help.

You may want to try printing $email_body to see what it contains. I suspect that the special characters might be escape, in which case you'll need to use stripslashes() on it prior to putting it into the e-mail. Can't be sure though, need to see what $email_body contains.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.