| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe and Support WebmasterWorld|
|New lines in mails generated by php|
| 7:30 pm on Oct 3, 2007 (gmt 0)|
I was wondering how I can best create new lines in mails via php. Should I add \n to the message or <br>?
| 7:38 pm on Oct 3, 2007 (gmt 0)|
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.
| 7:48 pm on Oct 3, 2007 (gmt 0)|
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.
| 11:50 pm on Oct 3, 2007 (gmt 0)|
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.
© Webmaster World 1996-2014 all rights reserved