| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|New lines in mails generated by php|
I was wondering how I can best create new lines in mails via php. Should I add \n to the message or <br>?
It depends on what you make the MIME type.
If you have ="text/html"
Then <br /> will work..
If you have ="text/plain"
Then typing returns into the code itself should do the job of adding space.
Adding \n will give you a line break in the source code if you have a html MIME type, but wont give you a visual break in the browser. Using <br /> will give you a visual break.
When making system-generated emails for my site (thanks for subscribing, etc) I usually set the body as a large text var like this:
$body = "Hello,
thanks for subscribing....
Also, may I mention that our forum is pack full of information....
More words here.....
This method will generate a text email with line breaks wherever I put them in the $body var. It is easier to work with than "\n" and works on both HTML and plain text mail readers.
Hope that helps.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved