I have written a newsletter function into my websites. When the emails are sent, the HTML content is pulled from a MySQL database and sent to the receivers through the php mail() function with the appropriate content-type html header.

This works great for the most part but I have since discovered that any apostrophes (') arrive in the inbox as either a question mark ? (in Thunderbird) or a square (in Outlook Express.)

This has been most frustrating and I can't seem to catch it. I have tried to replace ' with &#039 with both ereg_replace and str_replace to no avail.

using ereg will find the ' but ereg_replace will not replace the string with any given value.

Any help or pointers would be very appreciated.

    Have you tried adding a Content-Type header to the e-mails and using a charset like UTF-8 ?

      You might want to try this in case your editor has been inserting directional quotes into your text:

      $search = array(chr(145), chr(146), chr(147), chr(148));
      $replace = array("'", "'", '"', '"');
      $text = str_replace($search, $replace, $text);
      

        Thanks guys, the UTF-8 attempt left me with the same result. However, the suggestion from NogDog fixed it up.

          Write a Reply...