Mail function breaking message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Satterwhite

    Mail function breaking message

    I have a survey form that I want mailed to the client. I've built the
    message body as plain text and tested it by writing it to a file and
    examining the file. It's being built correctly.

    When I send it through mail by a command similar to:
    mail($to, 'Survey Results', $msgBody, "From: xxx@yyy.com");

    the message gets broken up. At periodic places in the file, I seea
    "!" (without the quotes) being inserted and the text format is broken.
    The only thing I can think of is some type of length restriction. The
    message isn't super long, but it isn't short either.

    Can anyone offer any help?


  • Matt Raines

    #2
    Re: Mail function breaking message

    On Sat, 5 Feb 2005, Michael Satterwhite wrote:
    [color=blue]
    > When I send it through mail by a command similar to:
    > mail($to, 'Survey Results', $msgBody, "From: xxx@yyy.com");
    >
    > the message gets broken up. At periodic places in the file, I seea
    > "!" (without the quotes) being inserted and the text format is broken.
    > The only thing I can think of is some type of length restriction. The
    > message isn't super long, but it isn't short either.[/color]

    I suspect the length of the individual lines in your message body, not the
    message as a whole, is causing the problem. I believe lines longer than a
    certain number of characters are truncated and an exclamation mark placed
    at the end of the line. This happened to me once using the built-in mail
    function with sendmail on a Linux box.

    Since you say your message is plain text, try running it through wordwrap:
    mail($to, 'Survey Results', wordwrap($msgBo dy), "From: xxx@yyy.com");

    This splits the string on word boundaries so that each line is not longer
    than 75 characters (by default).

    --
    Matt

    Comment

    • Michael Satterwhite

      #3
      Re: Mail function breaking message - FIXED

      Matt Raines wrote:
      [color=blue]
      > On Sat, 5 Feb 2005, Michael Satterwhite wrote:
      >[color=green]
      >> When I send it through mail by a command similar to:
      >> mail($to, 'Survey Results', $msgBody, "From: xxx@yyy.com");
      >>
      >> the message gets broken up. At periodic places in the file, I seea
      >> "!" (without the quotes) being inserted and the text format is broken.
      >> The only thing I can think of is some type of length restriction. The
      >> message isn't super long, but it isn't short either.[/color]
      >
      > I suspect the length of the individual lines in your message body, not the
      > message as a whole, is causing the problem. I believe lines longer than a
      > certain number of characters are truncated and an exclamation mark placed
      > at the end of the line. This happened to me once using the built-in mail
      > function with sendmail on a Linux box.
      >
      > Since you say your message is plain text, try running it through wordwrap:
      > mail($to, 'Survey Results', wordwrap($msgBo dy), "From: xxx@yyy.com");
      >
      > This splits the string on word boundaries so that each line is not longer
      > than 75 characters (by default).[/color]

      That was it. Thanks


      Comment

      Working...