Page 1 of 1

line breaks

Posted: Thu Mar 10, 2011 2:24 pm
by lubber123
I am having issues sending mail and changing the line breaks to breaks. I am sending an html email and the line breaks in the mail itself, when received, have \r\n and I have tried using nl2br() but I still get the same result:

Result: test13\r\n\r\ntest13\r\n\r\ntest13

Code: Select all

<p id='message'>" . nl2br($_REQUEST['message']) . "</p>
								  <p id='headers'>
								  From: " . $name . "<br />
								  Subject: " . nl2br($_REQUEST['subject']) . "<br />
								...
					 //Mail it
					if(mail($to, $subject, $message, $headers)){

Re: line breaks

Posted: Thu Mar 10, 2011 3:16 pm
by social_experiment
Try using "\r\n\r\n". nl2br inserts <br /> or <br > tags before a new line, you're email message probably just a plain text message which ignores <br /> (or <br >).

Re: line breaks

Posted: Thu Mar 10, 2011 3:47 pm
by lubber123
what do you mean by -- "\r\n\r\n". nl2br inserts

str_replace or insert in Db and then retrieve - sorry I am lost.

Re: line breaks

Posted: Fri Mar 11, 2011 3:43 pm
by social_experiment
lubber123 wrote:what do you mean by -- "\r\n\r\n". nl2br inserts
Apparently the line break tag (< br / >) was read as html. Use the value "\r\n\r\n" to create a new line break. the nl2br() function insert line break tags < br / > when a new line is encountered.