免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7239 | 回复: 6
打印 上一主题 下一主题

[Mail] 请教关于squirrelmail简体繁体乱码问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-01-29 14:32 |只看该作者 |倒序浏览
两个用户假如都是简体中文环境或者都是繁体中文环境,相互发邮件正常,但一方简体环境,另一方繁体环境时,收发的邮件都是乱码,需要改成相应的环境才能正常显示,有什么办法让系统自动转换吗?

论坛徽章:
0
2 [报告]
发表于 2008-01-29 15:17 |只看该作者
自己将自己的语言设置正确.

不要在英文设置下发其他语言的邮件. 也不要这样转发

论坛徽章:
0
3 [报告]
发表于 2008-01-29 15:21 |只看该作者
台湾和大陆的公司共用一个邮件系统,没办法啊

论坛徽章:
0
4 [报告]
发表于 2008-01-29 16:09 |只看该作者
你们用的什么邮件系统哦
没采用UTF-8的编码呀

论坛徽章:
0
5 [报告]
发表于 2008-01-29 16:19 |只看该作者
postfix

论坛徽章:
0
6 [报告]
发表于 2008-02-04 11:35 |只看该作者
我自己寫了一個patch,加入了charset detection功能,會依照郵件內的Content-Type或subject選擇合適的編碼,回覆和看附件時都會用同樣的encoding.....前提php要打開output_buffering.....如小弟的劣作有任何何bugs煩請告知,謝謝

diff -ruNb ../functions/i18n.php mail/functions/i18n.php
--- ../functions/i18n.php        2007-06-30 01:39:16.000000000 +0800
+++ ../functions/i18n.php        2007-10-29 07:52:07.000000000 +0800
@@ -468,6 +468,11 @@
     if ($my_language!='en_US') {
         $default_charset = $my_charset;
     }
+    //added by shing start
+    sqgetGlobalVar('charset', $charset, SQ_GET);
+        if ($charset!="")
+                $default_charset = $charset;
+    //added by shing end
}

/**
diff -ruNb ../functions/page_header.php mail/functions/page_header.php
--- ../functions/page_header.php        2007-07-14 21:04:00.000000000 +0800
+++ ../functions/page_header.php        2007-11-22 18:08:12.000000000 +0800
@@ -39,12 +39,42 @@
              $base_uri . 'themes/css/'.$custom_css.'">';
     }

+//added by shing start
+    global $charset, $mail_charset, $imapServerAddress, $imapPort ;
+    sqgetGlobalVar('charset', $charset, SQ_GET);
+    if (PAGE_NAME=="read_body") {
+
+        if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) {
+          $passed_id = (int) $temp;
+        }
+        if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
+          $mailbox = $temp;
+        }
+        if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
+          $passed_ent_id = '';
+        }
+        sqgetGlobalVar('key',        $key,          SQ_COOKIE);
+        sqgetGlobalVar('username',   $username,     SQ_SESSION);
+        sqgetGlobalVar('onetimepad', $onetimepad,   SQ_SESSION);
+        sqgetGlobalVar('delimiter',  $delimiter,    SQ_SESSION);
+
+        $imapConnection = sqimap_login($username, $key, $imapServerAddress,$imapPort, 0);
+        $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
+        $mail_charset = get_mail_charset($imapConnection,$passed_id, $passed_ent_id);
+    }
+//added by shing end
     if ($squirrelmail_language == 'ja_JP') {
         // Why is it added here? Header ('Content-Type:..) is used in i18n.php
         echo "<!-- \xfd\xfe -->\n";
         echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
     }

+// added by shing start
+    else if ($charset!="")
+               header('Content-type:text/html; charset='.$charset);
+    else if ($mail_charset!=false && !isset($_GET['charset']) )
+                header('Content-type:text/html; charset='.$mail_charset);
+//added by shing end
     if ($do_hook) {
         do_hook('generic_header');
     }
@@ -70,6 +100,34 @@
     $pageheader_sent = TRUE;
}

+//added by shing start
+function get_mail_charset($imapConnection,$id, $passed_ent_id) {
+    global $uid_support;
+
+    $header_full = array();
+    $header_output = array();
+    $second = array();
+    $first = array();
+
+    if (!$passed_ent_id) {
+        $read=sqimap_run_command ($imapConnection, "FETCH $id BODY[HEADER]", true, $a, $b, $uid_support);
+    } else {
+        $query = "FETCH $id BODY[".$passed_ent_id.'.HEADER]';
+        $read=sqimap_run_command ($imapConnection, $query, true, $a, $b, $uid_support);
+    }
+    $cnum = 0;
+
+    for ($i=1; $i < count($read); $i++) {
+        $line = $read[$i];
+        if (preg_match('/charset[ ]*=[ ]*["]?[\']?([a-zA-Z0-9_\\-]+)[\']?["]?/i', $line, $regs))
+            return $regs[1];
+        if (preg_match('/subject[ ]*:[ ]*=[ ]*\?([a-zA-Z0-9_\\-]+)\?/i', $line, $regs))
+                return $regs[1];
+     }
+      return false;
+}
+//added by shing end
+
function makeInternalLink($path, $text, $target='') {
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
     if ($target != '') {
diff -ruNb ../src/compose.php mail/src/compose.php
--- ../src/compose.php        2007-09-01 01:20:22.000000000 +0800
+++ ../src/compose.php        2007-10-28 23:19:05.000000000 +0800
@@ -1050,7 +1050,8 @@
             "// -->\n</script>\n\n";
     }

-    echo "\n" . '<form name="compose" action="compose.php" method="post" ' .
+/*added by shing*/ global $charset; if ($charset!="") $charseturl = "?charset=$charset";
+/*changed by shing */    echo "\n" . '<form name="compose" action="compose.php'.$charseturl.'" method="post" ' .
         'enctype="multipart/form-data"';
     do_hook('compose_form');

diff -ruNb ../src/read_body.php mail/src/read_body.php
--- ../src/read_body.php        2007-07-20 19:13:46.000000000 +0800
+++ ../src/read_body.php        2007-10-28 23:19:05.000000000 +0800
@@ -604,23 +604,35 @@
         }
         $s .= $topbar_delimiter . $next_link;
     }
+//added by shing start
+global $mail_charset;
+sqgetGlobalVar('charset', $charset, SQ_GET);
+if (trim($charset)!="")
+       $charseturl = "&amp;charset=".$charset;
+else if ($mail_charset!=false && !isset($_GET['charset']) )
+        $charseturl = "&amp;charset=".$mail_charset;
+//added by shing end

     $s .= '</small></td>' . "\n" .
           html_tag( 'td', '', 'right', '', 'width="33%" nowrap' ) . '<small>';
     $comp_action_uri = $comp_uri . '&amp;smaction=forward';
+    /*added by shing */ $comp_action_uri .= $charseturl;
     $s .= makeComposeLink($comp_action_uri, _("Forward"));

     if ($enable_forward_as_attachment) {
         $comp_action_uri = $comp_uri . '&amp;smaction=forward_as_attachment';
+    /*added by shing */ $comp_action_uri .= $charseturl;
         $s .= $topbar_delimiter;
         $s .= makeComposeLink($comp_action_uri, _("Forward as Attachment"));
     }

     $comp_action_uri = $comp_uri . '&amp;smaction=reply';
+    /*added by shing */ $comp_action_uri .= $charseturl;
     $s .= $topbar_delimiter;
     $s .= makeComposeLink($comp_action_uri, _("Reply"));

     $comp_action_uri = $comp_uri . '&amp;smaction=reply_all';
+    /*added by shing */ $comp_action_uri .= $charseturl;
     $s .= $topbar_delimiter;
     $s .= makeComposeLink($comp_action_uri, _("Reply All"));
     $s .= '</small></td></tr></table>';
@@ -671,6 +683,35 @@
          "</tr>\n";
     echo $s;

+    //added by shing start
+    global $mail_charset;
+    sqgetGlobalVar('charset', $charset, SQ_GET);
+    sqgetGlobalVar('auto', $auto, SQ_GET);
+    $sel = 'selected="selected"';
+    $pos = strpos($_SERVER['REQUEST_URI'], "&charset=");
+    if ($pos === false)
+            $href=$_SERVER['REQUEST_URI'];
+    else
+            $href = substr($_SERVER['REQUEST_URI'], 0, $pos);
+    $pos = strpos($href, "&auto=");
+    if ($pos != false)
+            $href = substr($href, 0, $pos);
+    if ($mail_charset!=false) $mail_charset_link = "&charset=$mail_charset";
+        echo "<tr>\n" .
+          html_tag( 'td', '', 'right', '', 'valign="middle" width="20%"' ) . '<b>' . _("Charset") . ":&nbsp;&nbsp;</b></td>\n" .
+          html_tag( 'td', '', 'left', '', 'valign="middle" width="80%"' ) .'
+          <select name="charset" onchange="JavaScript:location.href=\''.$href.'\'+this.value">
+                  <option value="&charset=">Default</option>
+                  <option value="&auto=true'.$mail_charset_link.'" '; if ($auto || !isset($_GET['charset'])) echo $sel;echo'>Auto (';if ($mail_charset==false) echo "none"; else echo $mail_charset; echo ")</option>\n";
+    $char_arr=array('big5', 'big5-hkscs', 'utf-8', 'gb2312', 'euc-kr', 'shift-jis');
+    foreach ($char_arr as $value) {
+        echo "<option value=\"&charset=$value\"";
+        if ($charset==$value && !$auto)
+                echo $sel;
+        echo ">$value</option>\n";
+    }
+     echo '</select></td></tr>';
+    //added by shing end
}

/***************************/

untitled.PNG (36.13 KB, 下载次数: 80)

untitled.PNG

论坛徽章:
0
7 [报告]
发表于 2009-01-16 12:41 |只看该作者
将.po文件都转换为utf-8编码,并将配置文件全改为utf-8格式就不会出现乱码了。
具体涉及到如下文件:
conf/config.ini.php的default_charset
function/i18n.php的lang[zh_CN][]和lang[zh_TW][]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP