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<[email protected]>"; 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. Link to comment https://forums.phpfreaks.com/topic/134750-solved-apostrophe-problem-in-mails/ 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<[email protected]>"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/134750-solved-apostrophe-problem-in-mails/#findComment-701706 Share on other sites More sharing options...
Andy17 Posted November 29, 2008 Author Share Posted November 29, 2008 Thank you for your help, Ken. Link to comment https://forums.phpfreaks.com/topic/134750-solved-apostrophe-problem-in-mails/#findComment-701732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.