PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Mail » Mail_Mime » Bug #1518

Wrong header Mime conversion

Details

Submitted2004-05-27 14:58 UTC
Fromstorozhilov at mail dot ru
StatusDuplicate
PackageMail_Mime
PHP Version4.3.6
OSFreeBSD 5.2.1-p5
Roadmaps(Not assigned)

Comments

[2004-05-27 14:58 UTC] storozhilov at mail dot ru

Description:
------------
When trying to send mail message with the subject, containing some words of non-vestern characters, theese words converted separately without spaces between them. But spaces must be converted too. Otherwise theese spaces are disappeares while displaying subject in E-Mail clients (KMail, Mozilla, etc.).

$ pear list
INSTALLED PACKAGES:
===================
PACKAGE VERSION STATE
Archive_Tar 1.1 stable
Console_Getopt 1.2 stable
DB 1.6.2 stable
HTTP 1.2.2 stable
Mail 1.1.3 stable
Mail_Mime 1.2.1 stable
Net_SMTP 1.2.3 stable
Net_Socket 1.0.1 stable
PEAR 1.3.1 stable
XML_Parser 1.0.1 stable
XML_RPC 1.1.0 stable

Reproduce code:
---------------
<?
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setHTMLBody($html);
$body = $mime->get(array(
'head_charset' => 'koi8-r',
'html_charset' => 'koi8-r'
));
$hdrs = $mime->headers(array(
'To' => 'vasyapupkin@vasya.com',
'Subject' = 'Ìàøà åëà êàøó'
));
$mail =& Mail::factory('mail');
$mail->send('me@myhost.com', $hdrs, $body);
?>

Expected result:
----------------
I expect to see in mutt (or other E-Mail client) following subject: 'Ìàøà åëà êàøó'

Actual result:
--------------
But I see: 'Ìàøàåëàêàøó'

[2004-08-22 15:52 UTC] support_nospam_ at sworld_nospam_ dot lv

i changed the code at the end of mime.php file from this:

$replacement = preg_replace('/([\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value);
$hdr_value = str_replace($value, '=?' . $this->_build_params['head_charset'] . '?Q?' . $replacement . '?=', $hdr_value);

to this:

$replacement = preg_replace('/([\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value);
$value .= '=20';
$hdr_value = str_replace($value, '=?' . $this->_build_params['head_charset'] . '?Q?' . $replacement . '?=', $hdr_value);

so, just added one string: $value .= '=20'; whicha adds at the end of each word a space, encoded as '=20'

i've not tested it a lot, but it seems to be working...

[2004-11-12 14:53 UTC] ed at avi dot ru

That problem and solution was already discussed here:

http://pear.php.net/bugs/bug.php?id=30

There's also the sample of the patched method.