chrispols Posted October 17, 2006 Share Posted October 17, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/24181-line-breaks-mail-rn-not-working/ Share on other sites More sharing options...
chrispols Posted October 17, 2006 Author Share Posted October 17, 2006 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.ThanksChris Quote Link to comment https://forums.phpfreaks.com/topic/24181-line-breaks-mail-rn-not-working/#findComment-109910 Share on other sites More sharing options...
HuggieBear Posted October 17, 2006 Share Posted October 17, 2006 The reason for this is because everything between single-quotes is interpreted as a literal string, and not interpolated by php as it would be if it were enclosed in double-quotes.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24181-line-breaks-mail-rn-not-working/#findComment-109916 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.