By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Double Spaces in Mail Messages

P: n/a
When I send a message using the mail command in PHP some e-mail
addresses somehow put two returns in place of one return, so this:

$message = "Test
Test2"

becomes

Test

Test2

But if I mail this:

$message = "Test \n Test2"

it works the same for all e-mail addresses. Why is it doing this? I use
Red Hat Linux and Apache.
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"Tim J." <no****@nospam.xcom> wrote in message
news:aP*****************@newsread2.news.atl.earthl ink.net...
When I send a message using the mail command in PHP some e-mail
addresses somehow put two returns in place of one return, so this:

$message = "Test
Test2"

becomes

Test

Test2

But if I mail this:

$message = "Test \n Test2"

it works the same for all e-mail addresses. Why is it doing this? I use
Red Hat Linux and Apache.


I've read that five times and I can't work out what you're on about. "two
returns in place of one return" - is this a reference to Windows' "\r\n"
notation versus Linux's "\n"?

Does RFC821 give you any ideas? http://www.ietf.org/rfc/rfc0821.txt

Garp
Jul 17 '05 #2

P: n/a
Garp wrote:
"Tim J." <no****@nospam.xcom> wrote in message
news:aP*****************@newsread2.news.atl.earthl ink.net...
When I send a message using the mail command in PHP some e-mail
addresses somehow put two returns in place of one return, so this:

$message = "Test
Test2"

becomes

Test

Test2

But if I mail this:

$message = "Test \n Test2"

it works the same for all e-mail addresses. Why is it doing this? I use
Red Hat Linux and Apache.

I've read that five times and I can't work out what you're on about. "two
returns in place of one return" - is this a reference to Windows' "\r\n"
notation versus Linux's "\n"?

Does RFC821 give you any ideas? http://www.ietf.org/rfc/rfc0821.txt

Garp


Let me try to be clearer, say I have a script like this:

<?php

$body = 'test
test2';

mail($email, $subject, $body, $headers);

?>

When I send that message from to an e-mail address on the domain I'm
working on (using the same servers I'm working on) I get this in the
e-mail body:

test

test2

But if I send that message to another e-mail address (Earthlink e-mail
address to be specific) it shows up like this:

test
test2

The way I want it to. But if I do this:

$body = "test \n test2";

it shows up correctly on both e-mail address.

This is troubling because I have a script that sends mail from a
textarea input and it shows up the way the first example does. Perhaps
this is because I'm using a Windows system to input text?

Jul 17 '05 #3

P: n/a

"Tim J." <no****@nospam.xcom> wrote in message
news:c6*****************@newsread2.news.atl.earthl ink.net...
Garp wrote:
"Tim J." <no****@nospam.xcom> wrote in message
news:aP*****************@newsread2.news.atl.earthl ink.net...
When I send a message using the mail command in PHP some e-mail
addresses somehow put two returns in place of one return, so this:

$message = "Test
Test2"

becomes

Test

Test2

But if I mail this:

$message = "Test \n Test2"

it works the same for all e-mail addresses. Why is it doing this? I use
Red Hat Linux and Apache.

I've read that five times and I can't work out what you're on about. "two returns in place of one return" - is this a reference to Windows' "\r\n"
notation versus Linux's "\n"?

Does RFC821 give you any ideas? http://www.ietf.org/rfc/rfc0821.txt

Garp


Let me try to be clearer, say I have a script like this:

<?php

$body = 'test
test2';

mail($email, $subject, $body, $headers);

?>

When I send that message from to an e-mail address on the domain I'm
working on (using the same servers I'm working on) I get this in the
e-mail body:

test

test2

But if I send that message to another e-mail address (Earthlink e-mail
address to be specific) it shows up like this:

test
test2

The way I want it to. But if I do this:

$body = "test \n test2";

it shows up correctly on both e-mail address.

This is troubling because I have a script that sends mail from a
textarea input and it shows up the way the first example does. Perhaps
this is because I'm using a Windows system to input text?


I was right then - you're editing your Linux scripts on a Windows machine
and the editor's saving carriage returns as "\r\n" pairs, which Linux is
treating as two "\n"s (well, not exactly, but the effect is the same).

See if your editor has an option to save CRLF as CR (HTML-Kit does, what I
use), but it's better style not to break literal strings over line
boundaries - aside from the nightmare CRLF problem, there's often trailing
spaces and stuff too.

Better to do this:
$body = join(" \n ",array("test","test2"));
Or this:
$body = "test \n".
" test2";

HTH
Garp
Jul 17 '05 #4

P: n/a
Garp wrote:
"Tim J." <no****@nospam.xcom> wrote in message
news:c6*****************@newsread2.news.atl.earthl ink.net...
Garp wrote:
"Tim J." <no****@nospam.xcom> wrote in message
news:aP*****************@newsread2.news.atl.ear thlink.net...
When I send a message using the mail command in PHP some e-mail
addresses somehow put two returns in place of one return, so this:

$message = "Test
Test2"

becomes

Test

Test2

But if I mail this:

$message = "Test \n Test2"

it works the same for all e-mail addresses. Why is it doing this? I use
Red Hat Linux and Apache.
I've read that five times and I can't work out what you're on about.
"two
returns in place of one return" - is this a reference to Windows' "\r\n"
notation versus Linux's "\n"?

Does RFC821 give you any ideas? http://www.ietf.org/rfc/rfc0821.txt

Garp


Let me try to be clearer, say I have a script like this:

<?php

$body = 'test
test2';

mail($email, $subject, $body, $headers);

?>

When I send that message from to an e-mail address on the domain I'm
working on (using the same servers I'm working on) I get this in the
e-mail body:

test

test2

But if I send that message to another e-mail address (Earthlink e-mail
address to be specific) it shows up like this:

test
test2

The way I want it to. But if I do this:

$body = "test \n test2";

it shows up correctly on both e-mail address.

This is troubling because I have a script that sends mail from a
textarea input and it shows up the way the first example does. Perhaps
this is because I'm using a Windows system to input text?

I was right then - you're editing your Linux scripts on a Windows machine
and the editor's saving carriage returns as "\r\n" pairs, which Linux is
treating as two "\n"s (well, not exactly, but the effect is the same).

See if your editor has an option to save CRLF as CR (HTML-Kit does, what I
use), but it's better style not to break literal strings over line
boundaries - aside from the nightmare CRLF problem, there's often trailing
spaces and stuff too.

Better to do this:
$body = join(" \n ",array("test","test2"));
Or this:
$body = "test \n".
" test2";

HTH
Garp

Thanks. I haven't figured out how to save CRLF as CR on my editor
(TextPad) but there's probably someway.

What should I do with data from textareas? How could I use join without
inserting "\n" for every space?
Jul 17 '05 #5

P: n/a
no****@nospam.xcom says...
Thanks. I haven't figured out how to save CRLF as CR on my editor
(TextPad) but there's probably someway.


TextPad hasn't got a "save in UNIX format" configuration option??

Maybe you should look at other editors. I'm more than happy with my
freeware Crimson Editor, which definitely has this option.

Geoff M
Jul 17 '05 #6

P: n/a
gmuldoon wrote:
no****@nospam.xcom says...

Thanks. I haven't figured out how to save CRLF as CR on my editor
(TextPad) but there's probably someway.

TextPad hasn't got a "save in UNIX format" configuration option??

Maybe you should look at other editors. I'm more than happy with my
freeware Crimson Editor, which definitely has this option.

Geoff M


Yes, it does have that option. I just didn't find right away.
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.