Mail function breaking message

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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:");

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?

Re: Mail function breaking message

On Sat, 5 Feb 2005, Michael Satterwhite wrote:

Quoted text here. Click to load it

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($msgBody), "From:");

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


Re: Mail function breaking message - FIXED

Matt Raines wrote:

Quoted text here. Click to load it

That was it. Thanks

Site Timeline