Andy17 Posted November 29, 2008 Share Posted November 29, 2008 Hey, I have this mail script but my apostrophes are replaced with ' in the titles. I am sending HTML mails, so I believe it's a problem with the HTML encoding, but I am not sure. There is no problem in the mail text itself, just the title. Here is some of my code (the interesting part): $mail = htmlspecialchars($_POST['receivermail'], ENT_QUOTES); $mail = trim($mail); $mail = strip_tags($mail); $subject = htmlspecialchars($_POST['subject'], ENT_QUOTES); $subject = trim($subject); $subject = strip_tags($subject); $message = htmlspecialchars($_POST['mailtext'], ENT_QUOTES); $message = trim($message); $message = strip_tags($message); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "from: dizzit.net<no-reply@dizzit.net>"; mail($mail, $subject, $message, $headers); For example, this title: "I'm testing" would appear like this in the title field: "I'm testing". If you want to see for yourself, you can try it here. Thank you for your help. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 29, 2008 Share Posted November 29, 2008 You should not use the htmlspecialchars() function on the subject or To address of the mail message, since they are always treated as ASCII. Also strip_tags should be used first. <?php $mail = trim(strip_tags($_POST['receivermail'])); $subject = trim(strip_tags($_POST['subject'])); $message = trim(htmlspecialchars(strip_tags($_POST['mailtext']), ENT_QUOTES)); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: dizzit.net<no-reply@dizzit.net>"; ?> Ken Quote Link to comment Share on other sites More sharing options...
Andy17 Posted November 29, 2008 Author Share Posted November 29, 2008 Thank you for your help, Ken. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.