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
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)
Re: users management messages cannot be chinese error!!!
確定是這原因嗎? 查一下 server 的 mail log?
我是沒問題的~
Re: users management messages cannot be chinese error!!!
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)
...
有更好的解法嗎?
謝謝。