php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40923 mb_send_mail does not encode subject correctly
Submitted: 2007-03-26 16:34 UTC Modified: 2009-04-30 08:59 UTC
Votes:6
Avg. Score:3.8 ± 1.1
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: quasar at aero dot ist dot utl dot pt Assigned: moriyoshi (profile)
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: quasar at aero dot ist dot utl dot pt
New email:
PHP Version: OS:

 

 [2007-03-26 16:34 UTC] quasar at aero dot ist dot utl dot pt
Description:
------------
When trying to send an e-mail with international character in the subject, mb_send_mail is expected to fully encode the subject string. However it only encodes the string form the first word containing the interantional characters on.

Reproduce code:
---------------
// Assuming $to, $message and $headers already defined
$subject = "hello ?ll";
mb_send_mail($to, $subject, $message, $headers);

Expected result:
----------------
A fully encoded Subject header, in the form:

Subject: ?UTF-8?B?SOMETHING?=

Actual result:
--------------
Received e-mail relevant headers, as you can see the hello part of the string, which has no international, characters is left unencoded:

Subject: hello =?UTF-8?B?w6NsbA==?=
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit
Mime-Version: 1.0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-26 19:18 UTC] tony2001@php.net
Could you please point me to an RFC which says the actual result is incorrect?
 [2007-03-27 00:44 UTC] quasar at aero dot ist dot utl dot pt
After further reading of RFC2047 (http://www.ietf.org/rfc/rfc2047.txt) i have found this:

Ordinary ASCII text and 'encoded-word's may appear together in the same header field.  However, an 'encoded-word' that appears in a header field defined as '*text' MUST be separated from any adjacent 'encoded-word' or 'text' by 'linear-white-space'.

This implies that the function's behavior is actually correct, however it still creates problems with some e-mail clients.

I have filled this bug report following several bug reports on my end of people having e-mail clients inserting encoding tags in the middle of the subject.
For example (verified in pine): "hello [UTF-8]?ll".

Although it is now clear to me that the behaviour is in fact RFC2047 compliant, should it not be tweaked to make it more widely compatible with a greater variety e-mail clients?

(Perhaps this should be moved to a feature request, and i am sorry for the "false positive", i should have done my homework more carefully)
 [2007-04-01 15:23 UTC] moriyoshi@php.net
For the record, could you tell me the name of the e-mail client(s) your end of people used at the time of the problem?
 [2007-04-01 17:01 UTC] quasar at aero dot ist dot utl dot pt
Currently the problem has only been reported in pine (4.64) which is the default e-mail client for our system (300+ users).

It appends an encoding tag to the email subject, which appears in the middle of the subject if it is not fully encoded.

I know this isn't a real bug and you don't really have to "fix it", but i browsed through thousands of e-mail subjects on my own account and found out only the ones sent via our php interface show this subject encoding glitch.

According to RFC it is corect to only encode the part that needs to be encoded, however it does not appear to be the "standard policy" with all the e-mail sending software available.

Thanks for looking into this :)
 [2009-04-30 08:59 UTC] moriyoshi@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Forgot to mark this as a bogus bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC