The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: Mailer - New lines within textarea problem

  1. #1

    Mailer - New lines within textarea problem

    Got a php contact form set up and I've made the email it sends formatted with HTML.

        $headers .= "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
        $headers .= "From: $email" . "\r\n";
        $body .= "<html>";
        $body .= "<body>";
        $body .= //whatever
        $body .= "</body></html>";
        $body = wordwrap($body, 70);
        $body = stripslashes($body);
    It's all working except for one small problem that seems to be to do with the html formatting of the email...

    When the user types a message into the textarea message box, the email sent doesn't show where they have hit enter and gone to a new line. So their whole message is displayed in one long line, or paragraph, with no spacing.

    Does anyone know why this is happening? When I don't format it in html the spaces the user creates by entering down however many lines are displayed fine, but of course I can't make the font all pretty if I don't... =\

  2. #2
    PHP Code:
        $body wordwrap($body70); 
    $body stripslashes($body); 
    PHP Code:
        $body wordwrap($body70);
    $body nl2br($body);
    $body stripslashes($body); 
    nl2br stands for New Line to Break, wich converts all \n (from the textfield) to <br/>. Altho im not sure how an extra nl2br on the output of wordwrap will effect the results, im pretty sure you'll get close to what you want. give it a try.

    You can never underestimate the stupidity of the general public.

  3. #3
    Thank you!

    I've played around with it a bit and it seems to be working almost perfectly now. Just have to iron out a few things.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012