|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-04-13 21:59 UTC] jc at mega-bucks dot co dot jp
I am using mb_encode_mimeheader() and it seems that the function does not work properly on long subject lines ...
$headers = "MIME-Version: 1.0\n" ;
$headers .= "From: $from <$from_email>\r\n";
$headers .= "Reply-To: $from <$from_email>\r\n";
$headers .= "Content-Type: text/plain;charset=ISO-2022-JP\n";
$body = mb_convert_encoding($body, "ISO-2022-JP","AUTO");
$subject = "【tokyo-avland】公的証明書の送付期限のお知らせ";
/*
If I cut the subject to be
$subject = "【tokyo-avland】公的証明書の送付";
There is no problem. Problems occur if I I put characters
after this ... This doens't work either:
$subject = "【tokyo-avland】公的証明書の送付";
$subject .= "期限のお知らせ";
*/
mb_language("ja");
$subject = mb_convert_encoding($subject, "ISO-2022-JP","AUTO");
$subject = mb_encode_mimeheader($subject);
mail($to, $subject, $body, $headers, $sendmail_params);
The mail I receive has the following subject line:
Subject: =?ISO-2022-JP?B?GyRCIVobKEJ0b2t5by1hdmxhbmQbJEIhWzh4RSo+WkxAPXEkTkF3SVU0?=
=?ISO-2022-JP?B?fDhCJE4kKkNOJGkkOxsoQg==?=
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 23:00:01 2025 UTC |
gullevek at gullevek dot org: If the string is really encoded in ISO-2022-JP already and you are trying to transform it into the MIME encoded form, The code should be like the following: mb_internal_encoding("ISO-2022-JP"); $string=mb_encode_mimeheader(#string, "ISO-2022-JP"); By contrast to other functions, mb_encode_mimeheader() doesn't take any parameter that specifies the encoding of the source string, if you have to explicitly pass it to the function, you should call mb_internal_encoding() followed by a mb_encode_mimeheader().This is actually a user error: $subject = "【tokyo-avland】公的証明書の送付期限のお知らせ"; $subject = mb_encode_mimeheader($subject); Correct it must be: $subject = mb_encode_mimeheader("Subject: " . $subject); I was puzzling about that for a long time, too, until I got it: where else is mb_encode_mimeheader supposed to know when to break from?