Page 1 of 1

Email module and character set

PostPosted: Thu Oct 06, 2011 4:56 am
by jvinolas
Hi,

I'm sending emails correctly with the email module. The problem is with character set, so when I send special chars like "óñ..." they are shown as garbage.

Do I have to modify anything in Email module so it processes the chars correctly?

Thanks.

Re: Email module and character set

PostPosted: Thu Oct 06, 2011 10:08 am
by shannah
Are you copying and pasting into the email from another program, or are you entering directly into the email field?

Re: Email module and character set

PostPosted: Wed Oct 19, 2011 4:11 am
by jvinolas
Hi

I'm writing it directly from keyboard. This is an extract from the contents of the email, I think maybe could it be caused by debian locate? I can't see in this email header the charset 'us-ascii'.

Code: Select all
                                                                                                                                                                                                                                         

X-Mailer: XPM4 v.0.5 < www.xpertmailer.com >
Content-Type: multipart/alternative;
   boundary="=_"
MIME-Version: 1.0

This is a message in MIME Format. If you see this, your mail reader does not support this format.

--=_
Content-Type: text/plain;
   charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Prova de mail VI=C3=91OLAS AUQUER=09=09=09

Content-Type: text/html;
   charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Prova de mail VI=C3=91OLAS AUQUER=09=09=09<hr />

--=_


Re: Email module and character set

PostPosted: Mon Nov 28, 2011 8:54 am
by jvinolas
I solved it adding the charset and encoding to email.php (in dataface/modules/Email/actions). I modified this two lines (adding the code: ,'iso-8859-1','8bit'):
Code: Select all
// set text/plain version of message
$text = MIME::message(htmlspecialchars_decode(strip_tags(preg_replace(array('/<br[^>]*>/i','/<div[^>]*>/i','/<p[^>]*>/i', '/<table[^>]*>/i'), array("\r\n","\r\n","\r\n","\r\n"),$content))), 'text/plain','iso-8859-1','8bit');
// set text/html version of message
$html = MIME::message($html_content, 'text/html','iso-8859-1','8bit');

Re: Email module and character set

PostPosted: Mon Nov 28, 2011 10:59 am
by shannah
Thanks a lot. I have made a small variation on this fix and committed it to SVN:

Code: Select all

Index: email.php
===================================================================
--- email.php   (revision 3072)
+++ email.php   (revision 3073)
@@ -313,9 +313,9 @@
         $id = MIME::unique();
         
         // set text/plain version of message
-         $text = MIME::message(htmlspecialchars_decode(strip_tags(preg_replace(array('/<br[^>]*>/i','/<div[^>]*>/i','/<p[^>]*>/i', '/<table[^>]*>/i'), array("\r\n","\r\n","\r\n","\r\n"),$content))), 'text/plain', null, MIME::HCHARSET);
+         $text = MIME::message(htmlspecialchars_decode(strip_tags(preg_replace(array('/<br[^>]*>/i','/<div[^>]*>/i','/<p[^>]*>/i', '/<table[^>]*>/i'), array("\r\n","\r\n","\r\n","\r\n"),$content))), 'text/plain', $app->_conf['oe'], MIME::HCHARSET);
         // set text/html version of message
-         $html = MIME::message($html_content, 'text/html', null, MIME::HCHARSET);
+         $html = MIME::message($html_content, 'text/html', $app->_conf['oe'], MIME::HCHARSET);
         // add attachment with name 'file.txt'
         //$at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment');
         //$file = 'xpertmailer.gif';



In this case I'm using the encoding of the application (iso-8859-1 if monolingual english, utf-8 otherwise) rather than hardcoding it.

-Steve