舊版(1.6 ~ 1.9版)Moodle FAQ

為何本校的 WebMail 收到本系統的 EMail 都顯示亂碼, 如何解決?

為何本校的 WebMail 收到本系統的 EMail 都顯示亂碼, 如何解決?

admin 系統管理發表於
Number of replies: 3

User 如果用 Outlook Express 或 Outlook 收信應該不會有問題.

這個問題是本校的 Webmail 的問題, 因為 Webmail 不會自動偵測

郵件的編碼方式, 本系統的 Email 編碼是採國際通用的 UTF-8, 而

WebMail 是以 Big5 去開所有的信, 因此會有亂碼, 此問題負責管

理 WebMail 的計中網路組早已知道但無法解決.

    User 自行解決問題方式: 在打開亂碼信件後, 在亂碼信件內容區,

按 Mouse 右鍵, 點 [編碼], 選 [Unicode UTF-8], 如下圖:

webmail encode utf8

                        計網中心系統組   簡文章

In reply to admin 系統管理

回應: 為何本校的 WebMail 收到本系統的 EMail 都顯示亂碼, 如何解決?

jshin 張景新發表於

I had inspected the raw quote-printable formated mails. My guess is:

The PhpMail used by the Moodle does not generate the following meta data such that the browsers cannot detect UTF-8 encoding automatically:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

(It also does not produce the <html>...</html> pair before the <header> and after the </body> tags, which appears to me a bug or at least a fault.) 微笑

It is not the problem of the WebMail (or any other browsers) since (probably) no browser had implemented the code detecting mechanism but relying on the meta tag.

One way to correct this problem is to fix source codes of the PhpMail so that it add the above meta tag in the <header> section. (And, pre-/append the required <html> tag pairs, which would be safer.)

You may find the place to printf() this meta tag easily by conducting some educated guesses and using the search functions of your editor to search/find the '<header>' part. You then add a printf() after the output statement(s) that produces the <header> tag.

It often works to fix a big software this way for some minor bugs.

-JS

 

In reply to jshin 張景新

回應: 為何本校的 WebMail 收到本系統的 EMail 都顯示亂碼, 如何解決?

admin 系統管理發表於

張老師您好:

    我檢查了一封由 moodle 寄給我的信, 如下:

moodle 是有加下

Content-Type: text/plain; charset = "UTF-8" 

Content-Type: text/html; charset = "UTF-8"

charset 編碼設定, 但在 html 內容沒有加

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

我剛剛依您的建議改了 Phpmail 的 source code, 加了

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

測試了寄一封信給自己, NCNU webmail 收信, 主旨仍然是顯示亂碼,

這個無解, 但內容編碼已 auto detect 設為 UTF-8, 非常謝謝您的建議.

                                      計網中心系統組 簡文章

========================================================

Received: from 163.22.4.163
 by sunday.ncnu.edu.tw with NCNU EMail Ver. 0.3(27981:12:AUTH_RELAY)
 Wed, 04 Oct 2006 22:55:23 +0800 (CST);
 (envelope-from <wcchien@ncnu.edu.tw>)
Return-Path: <wcchien@ncnu.edu.tw>
Date: Wed, 4 Oct 2006 14:55:16 +0000
Return-Path: wcchien@ncnu.edu.tw
To: =?UTF-8?B?YWRtaW4g57Ch5paH56ug?= <wcchien@ncnu.edu.tw>
From: =?UTF-8?B?OTUxMDcwMjQg6buD5oOg6Zuv?=
Subject: =?UTF-8?B?6ICB5bir5L2g5aW977yM5oiR5LiN5bCP5b+D5oyJ5Yiw5Yqg5YWl5a24?=
 =?UTF-8?B?5ZOh5LqG44CC6KuL5ZWP5pyD5oCO5qij5ZeOP+isneisneaCqOeahA==?=
 =?UTF-8?B?5oyH5pWZ44CCLi4u?=
Message-ID: <a85fd7a999b017fbd5e7afa6b7d9a2ff@moodle.ncnu.edu.tw>
X-Priority: 3
X-Mailer: PHPMailer [version Moodle 2006050521]
MIME-Version: 1.0
Content-Type: multipart/alternative;

 boundary="b1_a85fd7a999b017fbd5e7afa6b7d9a2ff"


--b1_a85fd7a999b017fbd5e7afa6b7d9a2ff
Content-Type: text/plain; charset = "UTF-8"
Content-Transfer-Encoding: quoted-printable


=E8=80=81=E5=B8=AB=E4=BD=A0=E5=A5=BD=EF=BC=8C=E6=88=91=E4=B8=8D=E5=B0=8F=
=E5=BF=83=E6=8C=89=E5=88=B0=E5=8A=A0=E5=85=A5=E5=AD=B8=E5=93=A1=E4=BA=86=
=E3=80=82=E8=AB=8B=E5=95=8F=E6=9C=83=E6=80=8E=E6=A8=A3=E5=97=8E?=E8=AC=9D=
=E8=AC=9D=E6=82=A8=E7=9A=84=E6=8C=87=E6=95=99=E3=80=82

--
=E9=80=99=E5=B0=81=E9=83=B5=E4=BB=B6=E6=98=AF=E5=9C=A8=E2=80=9C
http://moodle.ncnu.edu.tw/message/index.php?popup=3D1


--b1_a85fd7a999b017fbd5e7afa6b7d9a2ff
Content-Type: text/html; charset = "UTF-8"
Content-Transfer-Encoding: quoted-printable

<p>=E8=80=81=E5=B8=AB=E4=BD=A0=E5=A5=BD=EF=BC=8C=E6=88=91=E4=B8=8D=E5=B0=
=8F=E5=BF=83=E6=8C=89=E5=88=B0=E5=8A=A0=E5=85=A5=E5=AD=B8=E5=93=A1=E4=BA=
=86=E3=80=82=E8=AB=8B=E5=95=8F=E6=9C=83=E6=80=8E=E6=A8=A3=E5=97=8E?=E8=AC=
=9D=E8=AC=9D=E6=82=A8=E7=9A=84=E6=8C=87=E6=95=99=E3=80=82</p><hr /><p><a =
href=3D"http://moodle.ncnu.edu.tw/message/index.php?popup=3D1">=E9=80=99=
=E5=B0=81=E9=83=B5=E4=BB=B6=E6=98=AF=E5=9C=A8=E2=80=9C</a></p>

 

--b1_a85fd7a999b017fbd5e7afa6b7d9a2ff--


 

In reply to admin 系統管理

回應: 為何本校的 WebMail 收到本系統的 EMail 都顯示亂碼, 如何解決?

jshin 張景新發表於

>> 主旨仍然是顯示亂碼, 這個無解, 但內容編碼已 auto detect 設為 UTF-8

這是因為 Webmail 會把 quoted-printable (QP) encode 的「主旨」decode 回來成為 binary codes (不需要知道什麼碼), 可是沒將他轉碼 (不支援). 這確實是 Webmail 的問題.

而內容部份, 經過 decode 後, 直接 pass 給 browser 顯示; 只要 browser 有支援 utf-8, 就能顯示正確. (不關 Webmail 的事).

要解決這個問題有兩種方法:

(1) 在 Webmail QP decode 之後, 把 subject (甚至 html body都) 轉成 big5 (當然, 如果連 html body 都轉, 也要把 meta tag 的 charset 順便改成 big5).

(2) 不改 Webmail source, 而在 moodle/phpmail 將 utf-8 轉碼為 big5 之後, 再用 Base64/QP 格式分別將 subject/body 轉成 ascii characters 送出來. (當然, subject/from/to 的 B64 prefix 改成 '=?big5?B?...?=', html body 內的 meta tag 的 charset 改為 big5.

轉碼的程式 source code (in C) 我應該有 (utf-7/utf-8 <=> big5/gb). 只是不知道塞到哪裡去了. 大笑 你用 Google 一下 'u8tob5', 'b5tou8', 'u8togb', 'gbtou8, 'u8tou7', 'u7tou8', 'u8touni', 'unitou8' 大概就找得到. 交大的 ftp 應該也有.

找不到再跟我講 !!