Double Spaces in Mail Messages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim J.

    Double Spaces in Mail Messages

    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.
  • Garp

    #2
    Re: Double Spaces in Mail Messages


    "Tim J." <nospam@nospam. xcom> wrote in message
    news:aPEEc.2674 $yy1.2303@newsr ead2.news.atl.e arthlink.net...[color=blue]
    > 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.[/color]

    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


    Comment

    • Tim J.

      #3
      Re: Double Spaces in Mail Messages

      Garp wrote:[color=blue]
      > "Tim J." <nospam@nospam. xcom> wrote in message
      > news:aPEEc.2674 $yy1.2303@newsr ead2.news.atl.e arthlink.net...
      >[color=green]
      >>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.[/color]
      >
      >
      > 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
      >
      >[/color]

      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?

      Comment

      • Garp

        #4
        Re: Double Spaces in Mail Messages


        "Tim J." <nospam@nospam. xcom> wrote in message
        news:c6HEc.2834 $yy1.1062@newsr ead2.news.atl.e arthlink.net...[color=blue]
        > Garp wrote:[color=green]
        > > "Tim J." <nospam@nospam. xcom> wrote in message
        > > news:aPEEc.2674 $yy1.2303@newsr ead2.news.atl.e arthlink.net...
        > >[color=darkred]
        > >>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.[/color]
        > >
        > >
        > > I've read that five times and I can't work out what you're on about.[/color][/color]
        "two[color=blue][color=green]
        > > 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
        > >
        > >[/color]
        >
        > 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?[/color]

        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


        Comment

        • Tim J.

          #5
          Re: Double Spaces in Mail Messages

          Garp wrote:[color=blue]
          > "Tim J." <nospam@nospam. xcom> wrote in message
          > news:c6HEc.2834 $yy1.1062@newsr ead2.news.atl.e arthlink.net...
          >[color=green]
          >>Garp wrote:
          >>[color=darkred]
          >>>"Tim J." <nospam@nospam. xcom> wrote in message
          >>>news:aPEEc.2 674$yy1.2303@ne wsread2.news.at l.earthlink.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.[/color][/color]
          >
          > "two
          >[color=green][color=darkred]
          >>>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
          >>>
          >>>[/color]
          >>
          >>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?[/color]
          >
          >
          > 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
          >
          >[/color]
          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?

          Comment

          • gmuldoon

            #6
            Re: Double Spaces in Mail Messages

            nospam@nospam.x com says...
            [color=blue]
            > Thanks. I haven't figured out how to save CRLF as CR on my editor
            > (TextPad) but there's probably someway.[/color]

            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

            Comment

            • Tim J.

              #7
              Re: Double Spaces in Mail Messages

              gmuldoon wrote:
              [color=blue]
              > nospam@nospam.x com says...
              >
              >[color=green]
              >>Thanks. I haven't figured out how to save CRLF as CR on my editor
              >>(TextPad) but there's probably someway.[/color]
              >
              >
              > 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[/color]

              Yes, it does have that option. I just didn't find right away.

              Comment

              Working...