Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have searched in this forum but could not find an answer to this question. Hopefully somebody recognizes it and can help me out!

In our website we have build an email newsletter function. In fact, we build two: one aimed at members, one aimed at external subscribers. Our problem is that when we want to send an e-mail through our newsletter functionality that special characters (like single and double quotes) and diacrites (like ë and è, of which the Dutch language has quite a lot) are displayed incorrectly. A double quote, for instance, becomes " which does not make the e-mail well-readable.

In our newsletter function we simply build up the text from custom typed text or published news items, and prepare it for sending using this command:
Code: Select all
$text= nl2br(htmlspecialchars(utf8_encode($text),ENT_QUOTES | ENT_COMPAT,'UTF-8'));

Then, we use the cms:send_mail tag (stating html='1') to finally dispatch the message:
Code: Select all
<cms:send_mail to="<cms:show item />" from='newsletter@email.com' subject="<cms:show messagesubject />" html='1' >                     
      <cms:show messagehtml />
</cms:send_mail>

When we want to send an e-mail that includes the text "Corona-proof", it displays like this:
Code: Select all
&quot;Corona-proof&quot;

Does anyone happen to know an answer for this?
Since send_mail uses PHPMailer, it may have something to do with a setting somewhere?
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
..we simply build up the text from custom typed text or published news items..

I'd presume that both the input sources you mentioned above would be Couch managed; if so, I'd also presume that text from both, when displayed on the frontend (as opposed to in an email body), would be displaying without the reported problem. Is that correct?

If it is, then perhaps you don't need to further massage the source text using utf8_encode() and htmlspecialchars() (nl2br() shouldn't matter) -
Code: Select all
$text= nl2br(htmlspecialchars(utf8_encode($text),ENT_QUOTES | ENT_COMPAT,'UTF-8'));

Please try passing on the text straight from Couch to the email tag and let us know if that makes any difference.
Hi KK,
Yes your assumption is correct. The texts, when displayed on the front-end, are displayed with all the proper diacritics and quotes. OK I will try your suggestion!
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
3 posts Page 1 of 1