php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47868 Special apostrophe character stripped from subject
Submitted: 2009-04-01 21:30 UTC Modified: 2014-01-23 18:48 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: cconnors at online-buddies dot com Assigned:
Status: Not a bug Package: Mail related
PHP Version: 5.2.9 OS: win32 only - XPSP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cconnors at online-buddies dot com
New email:
PHP Version: OS:

 

 [2009-04-01 21:30 UTC] cconnors at online-buddies dot com
Description:
------------
The following character (?) is automatically stripped from a subject, but not the body using mail().

Quick fix is...

$subj = str_replace('?', '\'', $template->getSubject());

But it's not EXACTLY the same character.

I've played around with the header, and cannot get it to work with UTF-8.


Reproduce code:
---------------
header = "From: ". 'noreply' . 
	    " <" . 'noreply@foo.net' . ">\n" . 
	    "Reply-To: " . 'noreply@foo.net' . "\n" . 
	    "Content-type: text/plain; charset=UTF-8\n\n";

mail('fake@foo.net', 'french d?avoir' , 'french d?avoir', $header);

Expected result:
----------------
Should get a message with:

subject: french d?avoir
body: french d?avoir

Actual result:
--------------
Actually get: 

subject: french davoir
body: french d?avoir

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-06 20:36 UTC] astewart at online-buddies dot com
This is not a bug.

The header field must be encoded if you want non-ASCII characters in it, as in:


Subject: =?iso-8859-1?Q?french d=92avoir?=
 [2012-07-06 20:38 UTC] astewart at online-buddies dot com
Actually, that's not ISO-8859-1, that's Windows-1252:

    Subject: =?Windows-1252?Q?french d=92avoir?=

Which illustrates the problem neatly: You have to know the character encoding in 
use to make sense of non-ASCII characters.
 [2014-01-23 15:22 UTC] cmbecker69 at gmx dot de
Hm, the bug description is missing, but it seems astewart is
right that this is *not* *a* *bug*.
 [2014-01-23 18:48 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-01-23 18:48 UTC] requinix@php.net
The Wayback Machine has an archived copy with the description.

https://web.archive.org/web/20120723104144/https://bugs.php.net/bug.php?id=47868

mail() doesn't know what encoding the string you gave for the subject is so stripping out bytes that aren't allowed in 7-bit ASCII is IMO a fair resolution. You can easily encode the subject yourself with

  "=?iso-8859-1?Q?" . quoted_printable_encode("french d\x92avoir") . "?="
(if it's ISO-8859-1 encoding, otherwise you'll need a different string)

The relevant RFC is 2047 http://www.ietf.org/rfc/rfc2047.txt

Or, you know, use a mail library that does all this stuff for you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC