-2

I want to insert new line in mail body paragraphs .I have searched all the other same questions but none of them seems to work

$body = "Dear $surname  $name \r\n
Thank you for your Pre-registration for Global .\r\n
Please print the attached e-ticket with your personal barcode and bring it to the reception of the exhibition.\r\n
This barcode includes data about you which is required during registration. Having this barcode will considerably speed up the registration process
Organizing committee.\r\n".



$body = "Print e-ticket
              ($imageurl) .\r\n".

This method displays all in one line How to change it to display it properly ? Thank you

2 Answers2

1

If you use html format of your body then you must use <br> instead of \r\n

ps: you have twice $body = .... so your second one will overwrite the first

nospor
  • 4,190
  • 1
  • 16
  • 25
1

You can simply use <br> by setting text/html Content-type header in mail() function.

Like this,

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

You need to set the headers for mail() function as fourth parameter.

mail($to,$subject,$message,$headers);

Also use . to append your strings.

Like this,

$body .= "Print e-ticket
              ($imageurl) \r\n".

http://php.net/manual/en/function.mail.php

Alok Patel
  • 7,842
  • 5
  • 31
  • 47