Jump to content

Line Breaks - Mail \r\n not working


chrispols

Recommended Posts

Hi,
I've been looking all around but can't find exactly how to fix adding line breaks into my automated mail. Can someone tell me what to do to modify this code to get line breaks in.

<?php
$to      = $_POST['Email'];
$subject = 'This is the subject';
$message = 'Hello, this is an automated "\r\n" message <br> new line and text \r more line \r\n and another line';
$headers = 'From: [email protected]' . "\r\n" .
  'Reply-To: [email protected]' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

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

All I ever get is the actual \r \r\n "\r\n" in my mail..

Thanks a lot.
Link to comment
https://forums.phpfreaks.com/topic/24181-line-breaks-mail-rn-not-working/
Share on other sites

Hi, found the problem.
I had to change
$message = 'Hello, this is an automated "\r\n" message
new line and text \r more line \r\n and another line';
to
$message = "Hello, this is an automated \n\nmessage
new line and text \r more line \r\n and another line";

and it works.. just the double quotes.
Thanks
Chris

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.