Forum Moderators: coopster

Message Too Old, No Replies

PHP mail() problem

No newlines

         

DrDoc

5:40 am on Dec 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How come the text in the body is sent without any newlines?

$body = "foobar\nwidgets";
...doesn't work
$body = "foobar\r\nwidgets";
...doesn't work either

No matter what I try, in the e-mail I get "foobar widgets" :(

jatar_k

5:46 am on Dec 9, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



any specs

client, server etc.

DrDoc

5:50 am on Dec 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP 4.3.3 on RH Linux
...using qmail I think
Not quite sure, since it's shared hosting.

mlemos

6:07 am on Dec 9, 2003 (gmt 0)

10+ Year Member



The PHP mail() function may be problematic because it has bugs and limitations. Without more information it is hard to advise.

Anyway, you may want to try this <snip> that comes with workarounds for several problems of the mail() function.

[edited by: jatar_k at 5:29 pm (utc) on Dec. 9, 2003]
[edit reason] no self promo thanks [/edit]

DrDoc

6:15 am on Dec 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Usually I use PHPMailer, which works great. But this time I figured I might as well just use mail(), since all I need to do is send a simple text message.

Without more information it is hard to advise

What kind of information?

mlemos

6:39 am on Dec 9, 2003 (gmt 0)

10+ Year Member



Well the class above works with mail() function by default. Only sub-classes use other delivery methods like sendmail, qmail and SMTP. As I said the class comes with workarounds that overcome several of the mail() function problems, so you may want to try it.

Other than that, it is hard to tell anything else without seeing your code that sends the message as it could be a problem with many things.

jetboy_70

11:47 am on Dec 9, 2003 (gmt 0)

10+ Year Member



DrDoc, the email you're sending isn't HTML formatted is it? May seem like a stupid question, but it would explain the line-breaks not being picked up.

What happens if $body = "foobar<br>widgets";?

DrDoc

5:12 am on Dec 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, it's plain text.

...and I got it to work by not using an underscore immediately before or after a \n(ewline) -- so now it works.