refiking Posted January 2, 2008 Share Posted January 2, 2008 I am trying to place line breaks in a mail script. Everytime I send the email to myself, there is no line break. Here is the code: <?php $to = "xxx@mail.net"; $subject = "Test mail"; $one = "Hello! This is a simple email message."; $lb = "<br>"; $two = "Just checking to see how this turns out."; $message = $one . $lb . $two; $from = "xxx@test.com"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> Whenever I get the email, here is how it appears. Hello! This is a simple email message.<br>Just checking to see how this turns out. Quote Link to comment https://forums.phpfreaks.com/topic/84125-solved-what-am-i-missing/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 2, 2008 Share Posted January 2, 2008 A html < br > (without the spaces) tag only has meaning in a HTML document. You would need to send the email as an html email to get the br tag to work. Quote Link to comment https://forums.phpfreaks.com/topic/84125-solved-what-am-i-missing/#findComment-428232 Share on other sites More sharing options...
aschk Posted January 2, 2008 Share Posted January 2, 2008 Thus one of your headers should be "Content-type: text/html\n"; Don't forget the \n in the from part of your headers. Quote Link to comment https://forums.phpfreaks.com/topic/84125-solved-what-am-i-missing/#findComment-428238 Share on other sites More sharing options...
refiking Posted January 2, 2008 Author Share Posted January 2, 2008 Sorry. I am trying to send it as a php, not HTML. I already tried <br /> and it didn't work either. How can I create the line break in the email using php? Quote Link to comment https://forums.phpfreaks.com/topic/84125-solved-what-am-i-missing/#findComment-428240 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.