I have a variable say $message which contains the content to be sent in mail using php mail function. This variable $message will contain text that will also have line breaks. This variable data is being fetched from textarea of another file using ajax.
For instance, the actual text is:
Hello
This is a test message
So while sending mail ($message variable), I see Hello This is a test message, without line break. Is there a way to fix this?
You can use like that:
$message = str_replace ('<br>' , '
', $_POST['textarea']);
You can also use nl2br()
function here.
Make sue you are using HTML header in mail()
function.