Re: message encoding in bx_filters_platforms_form2mail

qMax <[email protected]>
Newsgroups gmane.comp.cms.bitflux.general
Message-ID <[email protected]>
Thursday, September 8, 2005, 6:11:31 PM, qMax wrote:
q> Due to utf8_decode in function submitFields,
q> message body became always 7bit latin-1.

Here's patch to recode message into charset specified in form:parameters.

using iconv - should always work.

-- 
 qMax

-- 
bitflux-cms mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bitflux-cms
form2mail-charset.diff (application/octet-stream, 1.4 KB)
--- inc/bx/filters/patforms/form2mail.php.orig	2005-07-27 10:00:09.000000000 +0700
+++ inc/bx/filters/patforms/form2mail.php	2005-09-08 18:37:39.000000000 +0700
@@ -5,7 +5,8 @@
     public function submitFields($params, $fields) {
         $headers = '';
         $headers .= "User-Agent: Flux CMS " . BXCMS_VERSION.'/'.BXCMS_REVISION ."\r\n";
-        $headers .= "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n";
+				$charset = !empty($params['charset']) ? $params['charset'] : "ISO-8859-1";
+				$headers .= "Content-Type: text/plain; charset=".$charset."\r\n";
         
         $from = 'Do not reply to this address <[email protected]>';
         if(!empty($params['emailFromField']) && !empty($fields[$params['emailFromField']])) {
@@ -29,10 +30,10 @@
         $emailSubject = bx_helpers_string::replaceTextFields($emailSubject, $fields);
         $emailBody = bx_helpers_string::replaceTextFields($emailBody, $fields);
         
-        // decode utf8 strings
-         $emailSubject = utf8_decode($emailSubject);
-         $emailBody = utf8_decode($emailBody);
-        
+        // recode utf8 strings
+				$emailSubject=iconv("utf8",$charset,$emailSubject);
+				$emailBody=iconv("utf8",$charset,$emailBody);
+
         if(!empty($params['emailTo'])) {        
             mail($params['emailTo'], $emailSubject, $emailBody, $headers);
             return TRUE;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.