Forum Moderators: coopster

Message Too Old, No Replies

line breaks not preserved from text area when mailed

         

MX_OnD

3:43 pm on May 29, 2006 (gmt 0)

10+ Year Member



Hi all,

I've got a strange wee problem, I'm using mail(); to send an email. Basically, contrary to my advice, all the user's information goes into one textarea with default text to prompt the user to input the necessary information.

this is the form I'm using, generated by PHP:
***************CODE**********************
echo("<form id=\"mailform\" method=\"POST\" >\n<p><textarea name=\"message\" cols=\"30\" rows=\"10\" class=\"boxes\" >");
echo("Name:\n");
echo("Email:\n");
echo("Tel:\n");
echo("Query:\n");
echo("*Please ensure your contact details are correct*\n");
echo("</textarea><input type=hidden name=\"recipient\" value=\"email@your.host.com\"><input type=\"submit\" value=\"Submit\" name=\"B1\" class=\"boxes\">" );
***************END OF CODE**********************

then I use my cleaner script to avoid injections and send the mail hence:

***************CODE**********************
$cleanMessage = cleanVar($_POST['message'],false,true,true);
mail("recipient@domain.com", "subject", $cleanMessage, "From: somebody@somedomain.com" );
***************END OF CODE**********************

the problem is that the email is arriving all on one line like this:

name:bob\r\nemail:dangerbob@bob.bob\r\ntel:jim\r\nquery:jones\r\n*please ensure your contact details are correct*\r\n

any ideas how I can preserve the line breaks?

thanks in advance

wrightee

5:29 pm on May 29, 2006 (gmt 0)

10+ Year Member



What does the cleaner script look like, since that's what's creating the message / bug?

eelixduppy

6:05 pm on May 29, 2006 (gmt 0)



You can try nl2br [us2.php.net].

MX_OnD

11:04 pm on May 29, 2006 (gmt 0)

10+ Year Member



thanks!

wrightee was rightee!

was stripping slashes in the cleaner function.

Cheers