fixing new lines from <textarea> in an email?

From: Date: Fri, 26 Jun 2009 16:27:51 +0000
Subject: fixing new lines from <textarea> in an email?
Groups: php.general 
Request: Send a blank email to php-general+get-294659@lists.php.net to get a copy of this message
I have staff fill out a form that contains a <textarea> with their problem description and emailed to me when they click submit. Staff will press enter in the text area, but I'm having problems converting the \r\n into a new line in the email that is sent to me, here is the code: $subject = "new support request #".mysqli_insert_id($mysqli); $message = "Hello, ".$_SESSION["full_name"]." has created a new support request. Please log in at <a href=\"http://intra/helpdesk\">MDAH Helpdesk</a>. The problem request is \"".htmlspecialchars(nl2br(str_replace('\r','',$_POST["problem"])))."\". and the best time to contact is \"".htmlspecialchars($_POST["contact_time"])."\"."; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$_SESSION["full_name"]."<".$_SESSION["username"]."@mdah.state.ms.us>" ."\r\n" ."X-Mailer: PHP/" . phpversion(); mail('awilliam@mdah.state.ms.us', $subject, $message, $headers); and here is an example email, notice the \n is still in the body of the email, and it needs to be converted to a new line in the email: Hello, Gwendolyn Jones has created a new support request. Please log in at MDAH Helpdesk <http://intra/helpdesk>. The problem request is "1 of 2 questions: I'm having trouble opening files from Jennifer, Susie, and Bill because they are working with a higher version of microsoft office. My version is 2003. Is there any way I could get an update on this?\n2 of 2 questions: I need permission to download a plug-in for the NPS site where I research NR properties.\nNeither of these questions/issues are urgent. Thanks. -Gwen". and the best time to contact is "Any time, phone # is cell". why isn't nl2br converting the \n to <br> in the email?

« previous php.general (#294659) next »