javascript - converting \n to <br/> still prints out the <br/> instead of processing -
javascript code
var contact_comments = $("#con_us_comment").val(); contact_comments = contact_comments.replace(/(?:\r\n|\r|\n)/g, '<br />'); $.post('post.php', {'con_us_comment':contact_comment}, function(data) { // stuff i'm doing reply post call }
php code takes raw data coming post , sends through email me.
$contact_comment = test_input($_post['con_us_comment']); $body .= "<br/><b>comments: </b> ".$contact_comment;
email sent body set shown above
the email output looks this:
comments: line 1<br />line 2<br />line 3
instead of:
comments: line 1 line 2 line 3
so replaces \n doesn't process
, instead shows text
any idea i'm doing wrong here?
set content-type: text/html in header of mail script if using php mail() function try adding
$headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; // additional headers $headers .= 'to: mary <mary@example.com>, kelly <kelly@example.com>' . "\r\n"; $headers .= 'from: birthday reminder <birthday@example.com>' . "\r\n"; $headers .= 'cc: birthdayarchive@example.com' . "\r\n"; $headers .= 'bcc: birthdaycheck@example.com' . "\r\n";
before mail($to, $subject, $message, $headers);
statement
Comments
Post a Comment