Bug #47868 [Opn->Nab]: Special apostrophe character stripped from subject

From: Date: Thu, 23 Jan 2014 18:48:30 +0000
Subject: Bug #47868 [Opn->Nab]: Special apostrophe character stripped from subject
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183976@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47868&edit=1 ID: 47868 Updated by: requinix@php.net Reported by: cconnors at online-buddies dot com Summary: Special apostrophe character stripped from subject -Status: Open +Status: Not a bug Type: Bug Package: Mail related Operating System: win32 only - XPSP2 PHP Version: 5.2.9 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2014-01-23 15:22:33] cmbecker69 at gmx dot de Hm, the bug description is missing, but it seems astewart is right that this is *not* *a* *bug*. ------------------------------------------------------------------------ [2012-07-06 20:38:27] 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. ------------------------------------------------------------------------ [2012-07-06 20:36:37] 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?= ------------------------------------------------------------------------ [2009-04-01 21:30:37] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=47868&edit=1

« previous php.bugs (#183976) next »