php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20529 Bad subject line when using JIS encoding
Submitted: 2002-11-20 19:19 UTC Modified: 2002-12-23 19:28 UTC
From: malek at idanet dot co dot jp Assigned:
Status: Not a bug Package: mbstring related
PHP Version: 4.3.0RC1 OS: red hat Linux 6.2
Private report: No CVE-ID: None
 [2002-11-20 19:19 UTC] malek at idanet dot co dot jp
Hi Ya,
  Basically I am using
PHP 4.3.0RC1 (but I have also noticed the same thing with PHP 4.3.0PR2 )
on Red Hat Linux 6.2
with Sendmail 8.9.3

I am basically trying to send a mail in Japanese,
I first encode the text into JIS then simply send as normal,
i.e.
<?
$subjectja=mb_convert_encoding("?f?C???[???|?[?g","JIS","SJIS");    // converts the SHIFT_JIS to JIS
echo mb_detect_encoding($subjectja);  // Check it is encoded properly which it is
echo $subjectja;  // Check the Browser has no problems with the encoding and works fine
mail($email,$subjectja,"test->".$subjectja,"Content-Type: text/plain;charset=\"iso-2022-jp\"\nContent-Transfer-Encoding: 7bit"); // mail
?>
however the subject line does not appear correctly. On viewing the email source I noticed that it is seemingly removing some characters from the Subject line JIS,
Subject:  $B%G%$%j!<%l%]!<%H (B     <--- this is the resulting subject line which is broken

test->$B%G%$%j!<%l%]!<%H(B    <--- this is the email body which works fine

 $B%G%$%j!<%l%]!<%H (B
$B%G%$%j!<%l%]!<%H(B

slightly different. Also if you take out the "test->" on the body part the body of the email will not to work.

p.s. there is no problems with 4.0,4.1 or 4.2

thanks,
Malek

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-19 22:57 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-20 01:58 UTC] malek at idanet dot co dot jp
Hi,
 Have just tried using the latest snapshot and the bug is still there, no change,
thanks,
Malek
 [2002-12-20 02:14 UTC] moriyoshi@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

You should prepare mime headers(subject line, etc.) to be encoded in base64. Please ask this kind of question at php-i18n@lists.php.net or php-users@php.gr.jp(if you can understand Japanese) which you can subscribe at the appropriate pages of http://www.php.net/ or http://www.php.gr.jp/ respectively, before posting this kind of question to the bug database.


 [2002-12-20 02:42 UTC] malek at idanet dot co dot jp
Hi Again,
  I think actually this does, the problem is to do with the way the php mail function handles the subject line, I don't think it is actually a problem with the mb_string hence I originally posted to Mail. 

This bug was not apparent in any other version of php, of which we have around 6 test servers and 5 main servers running. 

It has only started with the 4.3.0 versions. 

If you look closely you can will see that this also does not occur in the message body of the email, just the header. It seams that the mail function can no longer handle '?' character for some reason and replaces it with a blank space. 

In fact I do have a way around this which I am actively using. 
mb_language ( "ja");
mb_send_mail( .... ) which does not seem to be affected by this bug.

I do not mind using mb_send_mail() from now on if this issue is not going to be fixed but this is kinda annoying when you don't necessary always want to write Japanese emails or use the base64 encoded subject lines. 

Just to note, I know for a fact several big companies using php in Japan are going to start experiencing this problem very soon if the decide to upgrade to 4.3. As from what I have seen they all tend to use the mail function which has worked very well up to now rather that the mb_send_mail function.

Anyway thank for you help and time,
sorry that it could not be fixed,
thanks,
Malek

p.s. if after reading this you still think it not a bug please change back to bogus, just put on open now to make sure you get this mail.
 [2002-12-20 09:40 UTC] moriyoshi@php.net
mb_send_mail() is smart enough to choose the appropriate encoding for the language in which a mail is written. So it's not likely that you are bothered by unnecessary encoding performed by this function. See the test cases for mb_send_mail() that reside in ext/mbstring/tests/mb_send_mail*.phpt for detail.

Anyway you should use mb_send_mail() in case you want to send mails composed in the character sets other than US-ASCII or ISO-8859-* since some MUA don't accept bare multibyte-encoded strings.

Regards,
Moriyoshi
 [2002-12-23 19:28 UTC] malek at idanet dot co dot jp
Ok, thanks for the response,
Malek
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 11:01:28 2024 UTC