您在這裡

users management messages cannot be chinese error!!!

hosais's 的頭像
hosais 在 2008-06-25 (三) 10:57 發表

Hi,

Users management messages 中文化之後有問題, email 會無法送出(應是Subject 部份不可以有中文)

Administer >> User Management >> User Settings
中如果subject 有中文的話,就會寄不出去.

有人知道為什麼嗎?

Joseph Lee

I installed Drupal in a hosting server in the USA. When I put Chinese in the subject in the email, the system cannot send the email. 也許是因為我的 hosting company 是美國的吧。

I got the message as following:

Drupal have following warrning:
warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/h/o/s/hosais/html/includes/mail.inc on line 197.

我目前的解決方案,是直接改mail.inc.
Solution (Using UTF-8, base64)
I solved the problem by changing the /includes/mail.inc by adding the following code. The idea is change the subject as

$subject = “=?UTF-8?B?” . base64_encode($subject) . “?=”;

[Source code]
mail.inc, Line 186:

return mail(
$message['to'],
//mime_header_encode($message['subject']), <== marked this
//“=?UTF-8?B?” . base64_encode($subject) . “?=”;
mime_header_encode("=?UTF-8?B?".base64_encode($message['subject'])."?="), //<== added this line
// Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
// They will appear correctly in the actual e-mail that is sent.
str_replace("\r", '', $message['body']),
// For headers, PHP's API suggests that we use CRLF normally,
// but some MTAs incorrecly replace LF with CRLF. See #234403.
join("\n", $mimeheaders)

...

有更好的解法嗎?

謝謝。