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: admin@site.com' . "\r\n" .
  'Reply-To: admin@site.com' . "\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
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.