-2

Hello I have this kind of variable inside a mail function, but I wuld like to separate the text inside the string with diferent lines:

$email_body = "Dear Client,

Text Title one

Text Title on a new line
";

the final result inside the e-mail shuld be every line inside a new line. right now everything is inside the same line when I perform:

mail($to,$email_subject,$email_body,$headers);  
John Siniger
  • 875
  • 2
  • 16
  • 39
  • 1
    possible duplicate of [Creating A New Line In $body Of PHP Mail Function](http://stackoverflow.com/questions/8782119/creating-a-new-line-in-body-of-php-mail-function) – David Oct 25 '13 at 16:49
  • 1
    have you tried the newline character '\n'? – Jordan Oct 25 '13 at 16:49
  • Make sure your headers do not contain `Content-Type: text/html` (since I don't see full code) – Funk Forty Niner Oct 25 '13 at 16:51
  • After looking through your other questions, found [this one](http://stackoverflow.com/q/19546555/1415724) which contains `$headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' . "\r\n";` - so, if this is related, you will need to use the `\n` character for new lines, or use any of the examples given to you below. – Funk Forty Niner Oct 25 '13 at 17:03

2 Answers2

1

Just add nl2br PHP function to see the newlines, like this :

mail($to,$email_subject,nl2br($email_body),$headers);  
JoDev
  • 6,633
  • 1
  • 22
  • 37
0

you can use html and your desired inline css for your email template.

$email_body = "<html><body>";

$email_body. = "Dear Client,</br>";

$email_body. = "Text Title one,</br>";

$email_body. = "Text Title on a new line,</br>";

$email_body. = "</body></html>";

mail($to,$email_subject,$email_body,$headers);
Moeed Farooqui
  • 3,604
  • 1
  • 18
  • 23