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 = "[email protected]"; $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 = "[email protected]"; $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. 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. 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. 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? 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
Archived
This topic is now archived and is closed to further replies.