tcorbeil Posted April 17, 2007 Share Posted April 17, 2007 Hello, I'm using this line to send an email... mail($email2, "XXXX.com: Registration- Thank you.", $body, $headers); Now the variable $body is quite long and needs to be formated.. so i tried this: $body = "Welcome\nThis is a test\n1)blahblah\n2)blahblah"; Where the outcome i would expect is: Welcom This is a test 1)blahblah 2)blahblah.. obviously isn't formatting with '\n'... any other ways to format in variables or am i chasing a ghost? Thanks T. Quote Link to comment Share on other sites More sharing options...
Anzeo Posted April 17, 2007 Share Posted April 17, 2007 i think the function nl2br will work you need to use it like this <?php $body = nl2br($body); ?> Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted April 17, 2007 Share Posted April 17, 2007 i think the function nl2br will work you need to use it like this <?php $body = nl2br($body); ?> That would be for printing to the browser or sending an HTML formatted email. Try this: $body = "Welcome\n" ."This is a test\n" ."1)blahblah\n" ."2)blahblah"; Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 17, 2007 Author Share Posted April 17, 2007 Thanks HeyRay but it is not working.. my actual code starts off as $body= "Hello.\n\n".$UserName." blahblahblah... and when I check my email, the format is: Hello. Tim blahblahblah... where I would expect: Hello. Tim blahblahblah... ..any other ideas? T. Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 17, 2007 Author Share Posted April 17, 2007 actually HeyRay, the full code for my email is.. $headers = "From: xxxx@xxxxx.com \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; /*notice there aren't any \r\n after the second two header additions. This is what made this version work correctly*/ mail($email2, "xxxx.com: Registration- Thank you.", $body, $headers); does the the line "$headers.= "Content-Type: text/html; charset=ISO-8859-1 "; " have anything to do with formatting?? T. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 \r\n = Return & NewLine remove the \r Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 17, 2007 Author Share Posted April 17, 2007 MadTechie, I've tried with the \r, without it, all variations I can think of.. it still isn't formatting.. Is there another way I can go about? T. Quote Link to comment Share on other sites More sharing options...
Anzeo Posted April 17, 2007 Share Posted April 17, 2007 <\ br> could work? Quote Link to comment Share on other sites More sharing options...
rpadilla Posted April 17, 2007 Share Posted April 17, 2007 try this $body = "Welcome $name This is a test 1)blahblah 2)blahblah"; Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 17, 2007 Author Share Posted April 17, 2007 Didn't work... Quote Link to comment Share on other sites More sharing options...
Anzeo Posted April 17, 2007 Share Posted April 17, 2007 Try this: $body = "Welcome\n" ."This is a test\n" ."1)blahblah\n" ."2)blahblah"; shudn't it be $body = "text 1" $body .= "text2" and so on? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 17, 2007 Share Posted April 17, 2007 This line <?php $headers.= "Content-Type: text/html; charset=ISO-8859-1 ?> says that you're sending HTML formated email. Since this is the case, you need to use the "<br>" tag to get a newline to appear. Ken Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted April 17, 2007 Share Posted April 17, 2007 This line <?php $headers.= "Content-Type: text/html; charset=ISO-8859-1 ?> says that you're sending HTML formated email. Since this is the case, you need to use the "<br>" tag to get a newline to appear. Ken Nice catch kenrbnsn. I didn't even notice that. Quote Link to comment 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.