| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |
PHP Multilanguage Mail Header
If you have written a PHP application involving sending multilanguage headers, such as subject in Chinese, from in Japanese, etc.
You will probably notice that some mail clients such as Outlook does not translate these headers correctly.
The problem is that if these header fields are in different languages, proper encoding strings have to be prepended to it for mail clients to read them correctly. Furthermore, the string itself has to be base64 encoded. The following function will do the trick for you. BTW, you should only encode the "name" part of from and "subject" lines, do not encode anything else such as <email> fields.
function mb_mime_header($string, $encoding=null, $linefeed="\r\n") {
if(!$encoding) $encoding = mb_internal_encoding();
$encoded = '';
$encoded .= "=?$encoding?B?"
. base64_encode($string)
. "?=$linefeed";
return $encoded;
}

最新评论