homepage Welcome to WebmasterWorld Guest from 54.83.133.189
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
newline in PHP email scripts
re: previous posts
chriseccles2




msg:3807768
 11:39 am on Dec 15, 2008 (gmt 0)

Just browsing through older posts, I noticed the advice given regarding
the insertion of newline in PHP-generated email.
-
I have found that
'\r\n' often doesn't work with an Apache server.
This causes hours of frustration for anyone trying to figure why their
generated mail is always on one continuous line !
-
A better solution is always to use:

$messageText .= $messageText ."<br>";

for each line break needed.

Quite why the HTML tag works without breaking out of PHP is beyond
my ken, but it does, every time !

-
Chris

 

coopster




msg:3807829
 2:16 pm on Dec 15, 2008 (gmt 0)

Welcome to WebmasterWorld, chriseccles2.

I believe you are confused about two very different situations here. The mail headers do indeed require separation by newline, as per the mail RFC. Therefore, the \r\n must be coded properly.

However, if you are sending out HTML formatted mail, the only way to get your content separated is to use block elements in your HTML that are going to "push" the next block of information below the previous. An alternative is to wrap your $messageText in a set of HTML <pre></pre> tags and code your newlines that way.

To summarize, there is a difference between coding the message headers and the message content (body) itself.

jean123456




msg:3812418
 8:35 pm on Dec 21, 2008 (gmt 0)

"I have found that '\r\n' often doesn't work with an Apache server."

I have found that I need to use double quotes to make this work, that is use "\r\n"

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved