SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Dallas, Tx
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    odd little problem with mail() form

    I have not run into this problem before on forms submitted from websites. The current form is a long one (research questionnaire), so I won't display the entire thing here. But I believe I've just about narrowed down where the problem is cropping up, if not why.

    I have the form written, and it submits back to itself. Variables are trimmed and stripped, then checked to see if all required fields were submitted. Valid email address is checked for, then the message for mail() is put together with a series of $message .= statements.

    Now, all the data is being submitted fine...it all appears within the email received. But longer lines are ignoring the line feeds (\r\n). So, here's an example...


    Code:
    $message .="Age at first symptoms: $SymptomsAge\r\n";
    $message .="Method of diagnosis: $SymptomsDiagnosis\r\n";
    $message .="Where was the disease found in the body? $SymptomsWhere\r\n";
    $message .="Stage of lymphoma, if known: $SymptomsStage\r\n";
    $message .="Was the dog treated? $SymptomsTreated\r\n";
    $message .="For how long? $SymptomsLengthTreated\r\n";
    $message .="What treatment(s) were used? $SymptomsTreatments\r\n\r\n";
    This displays in the email as ...

    Code:
    Age at first symptoms: wer
    Method of diagnosis: awer
    Where was the disease found in the body? awer Stage of lymphoma, if known: awer Was the dog treated? No For how long? wer What treatment(s) were used? eawr
    I've been messing with this for a few hours, and the only thing I've discovered is that if I shorten the lines way up in the php, the line feeds for that line will work again. So if I change $message .="Where was the disease found in the body? $SymptomsWhere\r\n"; to $message .="Where was the disease? $SymptomsWhere\r\n"; then suddenly that line will have the appropriate line feed in the email. If I put in two line feeds rather than just one at the end of the misbehaving lines, then I get two line feeds in the email. If I leave just one LF in the php, I get none in the email. (But only on the long lines. The shorter ones are fine.)

    I'm stumped.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try wordwrap()

    my memory of it is vague, but i think i remember reading something about lines in emails should not exceed 75 or so characters. again, its a faint memory and i encourage you to read up on it yourself.

  3. #3
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Dallas, Tx
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    clam, I might be misunderstanding your suggestion. I'm not looking to wrap a line at a specific spot. I'm trying to figure out why some lines in my form are not honoring the line feed at the end of the php.

    I did try it though, and it had no affect whatsoever on the output to the email. I'm still getting run-on lines that are not honoring the line feeds I've added.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •