Welcome to WebmasterWorld Guest from 54.198.221.13

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

New lines in mails generated by php

     
7:30 pm on Oct 3, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Aug 29, 2003
posts:244
votes: 0


Hi,

I was wondering how I can best create new lines in mails via php. Should I add \n to the message or <br>?

Turbo

7:38 pm on Oct 3, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2609
votes: 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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 12, 2007
posts:766
votes: 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)

Junior Member

10+ Year Member

joined:Oct 3, 2007
posts:61
votes: 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.....

Thanks again!

Jon

";

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.

Jon

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members