Edit report at http://pear.php.net/bugs/bug.php?id=12216&edit=1
ID: 12216
Comment by: roger
Reported By: blomnik at gmail dot com
Summary: Incorrect Mail_mime::headers() behaviour (russian
text, utf8)
Status: Closed
Type: Bug
Package: Mail_Mime
Operating System: linux
Package Version: 1.5.2
PHP Version: 5.2.4
Assigned To: cipri
New Comment:
this bug is still remaining. I try to send letters with Russian text in
subject. Some of characters are not printable and displayed as ??. I
used this part of code:
$message->_build_params['head_encoding']='base64';
and amount of non-printable characters was decreased, but still
ramaining. Without this code subject was:
Subject:
=?utf-8?Q?0KHQutGA0LjQv9GCINC+0YLQv9GA0LDQstC60Lgg0L/QuNGB0LXQ?=
=?utf-8?B?vCAoMC4xLjMuMSk=?=
with "head_encoding = base64" subject is
Subject:
=?utf-8?B?0KHQutGA0LjQv9GCINC+0YLQv9GA0LDQstC60Lgg0L/QuNGB0LXQ?=
=?utf-8?B?vCAoMC4xLjMuMSk=?=
is it bug?
This is my mail script (body and subject contain Russian text. Body
displaying perfect!)
$text = '????????? ?????? ??????';
$html = '<html><body><h1>HTML ?????? ??????</h1><img
src="header-logo2.jpg" alt="Header Logo" /><p>?????? ?????????? ?
??????? ?????????? PEAR</p></body></html>';
$file = $abs_path.'/images/header-logo2.jpg';
$crlf = "\r\n";
$hdrs = array(
'From' => '[email protected]',
'Subject' => '?????? ???????? ????? (0.1.3.1)'
);
$mime = new Mail_mime($crlf);
$get_param = array(
"text_encoding" => "base64",
"html_encoding" => "base64",
"head_charset" => "utf-8",
"text_charset" => "utf-8",
"html_charset" => "utf-8"
);
$mime->_build_params['head_encoding']='base64';
$mime->setTXTBody($text);
$mime->addHTMLImage($file, 'image/jpeg');
$mime->setHTMLBody($html);
$body = $mime->get($get_param);
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$status = $mail->send('[email protected]', $hdrs, $body);
if (PEAR::isError($status))
{
print("ERROR: Mail not sent!");
}
Previous Comments:
------------------------------------------------------------------------
[2009-12-21 09:52:04] alec
<div id="changeset">
<span class="removed">-Status: Verified</span>
<span class="added">+Status: Closed</span>
</div>This bug has been fixed in SVN.
If this was a documentation problem, the fix will appear on
pear.php.net by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should
be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.
------------------------------------------------------------------------
[2009-08-25 08:05:41] cweiske
<div id="changeset">
<span class="removed">-Status: Feedback</span>
<span class="added">+Status: Verified</span>
</div>
------------------------------------------------------------------------
[2008-11-11 09:10:45] warl0rd
The problem is the extras '=?ISO-8859-1?Q?' (or other enconding code)
and '=?' that appear several times in the subject line after performing:
$headers = $mime->headers($headers);
A quick fix is to overwrite the $headers['subject'] with just one
'=?ISO-8859-1?Q?' at the start and the '=?' in the end.
$headers['subject']='=?ISO-8859-1?Q?'.$subject.'=?';
------------------------------------------------------------------------
[2008-08-15 19:36:30] m0r1arty
$message=new Mail_mime();
$message->_build_params['html_charset']='UTF-8';
$message->_build_params['text_charset']='UTF-8';
$message->_build_params['head_charset']='UTF-8';
$message->_build_params['head_encoding']='base64';
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
------------------------------------------------------------------------
[2008-06-27 07:06:12] jsandeo
I'm having the same problem.
The following source code is iso-8859-01
###################################
$subject = "This is just a subject line, which goes on for a few
characters, and on and on";
$cabeceras = array_merge(array('From' => $from), $array_to,
array('Subject' => $subject));
$body = $mime->get();
$hdrs = $mime->headers($cabeceras);
print_r($cabeceras);
print_r($hdrs); exit;
###################################
Output:
Array
(
[From] => IberGour [To] => [email protected]
[Cc] => [email protected]
[Subject] => This is just a subject line, which goes on for a few
characters, and on and on
)
Array
(
[MIME-Version] => 1.0
[From] => IberGour [To] => [email protected]
[Cc] => [email protected]
[Subject] => This is just a subject line, which goes on for a few
characters, and on and on
[Content-Transfer-Encoding] => 7bit
[Content-Type] => text/plain; charset="ISO-8859-1"
)
Whereas the following won't work:
###################################
$subject = "This is just a subject line España, which goes on for a
few characters, and on and on";
$cabeceras = array_merge(array('From' => $from), $array_to,
array('Subject' => $subject));
$body = $mime->get();
$hdrs = $mime->headers($cabeceras);
print_r($cabeceras);
print_r($hdrs); exit;
#################################
Output:
Array
(
[From] => IberGour [To] => [email protected]
[Cc] => [email protected]
[Subject] => This is just a subject line España, which goes on for
a few characters, and on and on
)
Array
(
[MIME-Version] => 1.0
[From] => IberGour [To] => [email protected]
[Cc] => [email protected]
[Subject] =>
=?ISO-8859-1?Q?This=20is=20just=20a=20subject=20line=20Espa=F1a?=
=?ISO-8859-1?Q?,=20which=20goes=20on=20for=20a=20few=20characters,=20an?=
=?ISO-8859-1?Q?d=20on=20and=20on?=
[Content-Transfer-Encoding] => 7bit
[Content-Type] => text/plain; charset="ISO-8859-1"
)
If I send this last message to a gmail account, it displays all messed
up, the subject being truncated at the second =?, and the rest of the
headers being displayed inside the text of the body.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=12216