Sending Plain Text Email

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sylvie Stone

    Sending Plain Text Email

    Hi All - I have created a survey and I would like the results of the
    survey to be emailed the boss in *plain text*.

    Can someone PLEASE take a look and tell me why carriage returns are
    not being inserted after each $body ? The email comes out as one big
    line.

    THANK YOU! Sylvie.

    include('Mail.p hp');
    include('Mail/mime.php');
    $body .= "Are you aware that SCC has a TDC?\n";
    $body .= "$_POST[one]\n";
    $body .= "Do you know that our resources are available to clients
    outside of SCC on an appointment basis?\n";
    $body .= "$_POST[three]\n";
    $body .= "Do you have occasion to reference the Virtual
    Library?<br>\n" ;
    $body .= "$_POST[four]\n";
    $body .= "Do you require access collections other than those
    available?\n";
    $body .= "$_POST[fivea]\n";
    $body .= "If so, please indicate which collections\n";
    $body .= "$collection\n" ;
    $body .= "Comments\n ";
    $body .= "$_POST[comments]\n";

    $crlf = "\r\n";
    $hdrs['From'] = 'anonymous@home .ca';
    $hdrs['To'] = 'theboss@home.c a';
    $hdrs['Subject'] = "TDC Survey for $_POST[year]";
    $mime = new Mail_mime($crlf );
    $mime->setTXTBody($bo dy);
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs) ;
    $mail =& Mail::factory(' mail');
    $mail->send('theboss@ home.ca', $hdrs, $body);
  • stephan beal

    #2
    Re: Sending Plain Text Email

    Sylvie Stone wrote:[color=blue]
    > Can someone PLEASE take a look and tell me why carriage returns are
    > not being inserted after each $body ? The email comes out as one big
    > line.[/color]


    This is a complete guess, but perhaps your boss' Windows email client is not
    properly translating \n to \r\n. Try an explicite \r\n and see what
    happens. A simpler way to do that, instead of doing $body .= "...\r\n" a
    bunch of times is:

    $body = array();
    $body[] = "....";
    $body[] = ".....";

    $body = join ( "\r\n", $body );


    --
    ----- stephan beal
    Registered Linux User #71917 http://counter.li.org
    I speak for myself, not my employer. Contents may
    be hot. Slippery when wet. Reading disclaimers makes
    you go blind. Writing them is worse. You have been Warned.

    Comment

    • fartsniff

      #3
      Re: Sending Plain Text Email

      "stephan beal" <stephan@wander inghorse.net> wrote in message
      news:bgr7bt$aja $1@ork.noris.ne t...[color=blue]
      > Sylvie Stone wrote:[color=green]
      > > Can someone PLEASE take a look and tell me why carriage returns are
      > > not being inserted after each $body ? The email comes out as one big
      > > line.[/color]
      >
      >[/color]

      if you use phpmailer, you can use altbody to create a text only message


      Comment

      • Ondrej Brablc

        #4
        Re: Sending Plain Text Email

        We had the same problem with MS Outlook. It simply decided it makes the
        text nicer and joined the lines. It showed a hint that some line break
        were removed, but we have overlooked it and spent some long minutes
        playing with \n and \r.

        Ondrej

        Sylvie Stone wrote:[color=blue]
        > Hi All - I have created a survey and I would like the results of the
        > survey to be emailed the boss in *plain text*.
        >
        > Can someone PLEASE take a look and tell me why carriage returns are
        > not being inserted after each $body ? The email comes out as one big
        > line.
        >
        > THANK YOU! Sylvie.
        >
        > include('Mail.p hp');
        > include('Mail/mime.php');
        > $body .= "Are you aware that SCC has a TDC?\n";
        > $body .= "$_POST[one]\n";
        > $body .= "Do you know that our resources are available to clients
        > outside of SCC on an appointment basis?\n";
        > $body .= "$_POST[three]\n";
        > $body .= "Do you have occasion to reference the Virtual
        > Library?<br>\n" ;
        > $body .= "$_POST[four]\n";
        > $body .= "Do you require access collections other than those
        > available?\n";
        > $body .= "$_POST[fivea]\n";
        > $body .= "If so, please indicate which collections\n";
        > $body .= "$collection\n" ;
        > $body .= "Comments\n ";
        > $body .= "$_POST[comments]\n";
        >
        > $crlf = "\r\n";
        > $hdrs['From'] = 'anonymous@home .ca';
        > $hdrs['To'] = 'theboss@home.c a';
        > $hdrs['Subject'] = "TDC Survey for $_POST[year]";
        > $mime = new Mail_mime($crlf );
        > $mime->setTXTBody($bo dy);
        > $body = $mime->get();
        > $hdrs = $mime->headers($hdrs) ;
        > $mail =& Mail::factory(' mail');
        > $mail->send('theboss@ home.ca', $hdrs, $body);[/color]

        Comment

        • Guest's Avatar

          #5
          Re: Sending Plain Text Email

          "Sylvie Stone" <sylviestone@ca nada.com> wrote in message
          news:181a24a8.0 308060718.33ae7 d8f@posting.goo gle.com...[color=blue]
          >
          > Can someone PLEASE take a look and tell me why carriage returns are
          > not being inserted after each $body ? The email comes out as one big
          > line.
          >[/color]
          <snip>[color=blue]
          >
          > $body .= "Do you have occasion to reference the Virtual
          > Library?<br>\n" ;[/color]

          If the email comes out as one big line it is because you are lacking line
          breaks <br>, which are not the same as new-line (\n). The only place you seem
          to have a line break is on the single line quoted above. The new-line
          character creates a line break in your resultant source code...not the HTML
          output.

          Try EITHER:
          a) Changing each instance of \n to <br>\n
          b) Running the output through nl2br()

          HTH!


          Comment

          Working...