FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=12411&edit=1

ID: 12411
Comment by: alec@alec.pl
Reported By: bmdevelopment at gmail dot com
Summary: Support RFC 2047 standard for non-ascii characters as
attachment filename.
Status: Open
Type: Feature/Change Request
Package: Mail_Mime
Operating System: FreeBSD 6.2-RELEASE #0
Package Version: 1.5.2
PHP Version: 5.2.4
Roadmap Versions:
New Comment:

Updated my bulk patch. Contains fixes for test scripts.


Previous Comments:
------------------------------------------------------------------------

[2009-12-03 13:39:38] alec

Added #patch bug:12411;patch:mime_bulk.patch;revision:1259847578;.

------------------------------------------------------------------------

[2009-06-17 11:59:40] alec

I've attached a bulk patch which addresses issues #12411, #12429,
#14232, #15320, #14529, #14779. Test script:
<?php

include('Mail/mime.php');

$text = '';
$crlf = "\n";
$file = 'empty.txt'; //some empty file
$files = array(
'empty.txt',
'with space.txt',
'with unicode &#380;&#261;&#347;&#378;&#263;.txt',
'long name with spaces, very long long long long long very very
long long.txt',
'long name with spaces, very long long long long long very very and
&#380;&#261;&#347;&#378;&#281;&#263;.txt',
);
$mime = new Mail_mime($crlf);

foreach ($files as $name) {
copy($file, '/tmp/'.$name);
$mime->addAttachment('/tmp/'.$name, 'text/plain', '', true,
'base64', 'attachment', 'UTF-8', '', '',
'quoted-printable');
}

$mime->setTXTBody($text);

echo $mime->getMessage();

?>

And result:

MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="=_8ea5f688b1cf8f2db7d4f37126f5ac3f"

--=_8ea5f688b1cf8f2db7d4f37126f5ac3f
Content-Transfer-Encoding: base64
Content-Type: text/plain charset=UTF-8;;
name=empty.txt;
Content-Disposition: attachment;
filename=empty.txt;


--=_8ea5f688b1cf8f2db7d4f37126f5ac3f
Content-Transfer-Encoding: base64
Content-Type: text/plain charset=UTF-8;;
name="with space.txt";
Content-Disposition: attachment;
filename="with space.txt";


--=_8ea5f688b1cf8f2db7d4f37126f5ac3f
Content-Transfer-Encoding: base64
Content-Type: text/plain charset=UTF-8;;
name="=?UTF-8?Q?with_unicode_=C5=BC=C4=85=C5=9B=C5=BA=C4=87.txt?=";
Content-Disposition: attachment;
filename*=UTF-8''with%20unicode%20%C5%BC%C4%85%C5%9B%C5%BA%C4%87.txt;


--=_8ea5f688b1cf8f2db7d4f37126f5ac3f
Content-Transfer-Encoding: base64
Content-Type: text/plain charset=UTF-8;;
name="long name with spaces, very long long long long long very very
lo.txt";
Content-Disposition: attachment;

filename*0*=UTF-8''long%20name%20with%20spaces,%20very%20long%20long%20long;
filename*1*=%20long%20long%20very%20very%20long%20long.txt;


--=_8ea5f688b1cf8f2db7d4f37126f5ac3f
Content-Transfer-Encoding: base64
Content-Type: text/plain charset=UTF-8;;

name="=?UTF-8?Q?long_name_with_spaces,_very_long_long_long_long_long_very_v.txt?=";

Content-Disposition: attachment;

filename*0*=UTF-8''long%20name%20with%20spaces,%20very%20long%20long%20long;

filename*1*=%20long%20long%20very%20very%20and%20%C5%BC%C4%85%C5%9B%C5%BA%C4;
filename*2*=%99%C4%87.txt;


--=_8ea5f688b1cf8f2db7d4f37126f5ac3f--

------------------------------------------------------------------------

[2009-06-17 11:54:36] alec

The following patch has been added/updated:

Patch Name: mime_bulk.patch
Revision: 1245236075
URL:
http://pear.php.net/bugs/patch-display.php?bug=12411&patch=mime_bulk.patch&revision=1245236075&display=1

------------------------------------------------------------------------

[2008-09-29 03:44:47] alec

mime_param.patch it's my patch for the same issue.

------------------------------------------------------------------------

[2007-11-18 14:23:40] cwiedmann
At the moment just some remarks:
OK, today I've had some time to rewrite the patch (against CVS). The
method Mail_mime::addAttachment() have now a tithe parameter:
@param bool $rfc2231 Allow the language to be used for
display the filename as well as
the character set.
Defaults to true
If you set this parameter to "false", the old behaviour is used. The
headers are encoded like e.g. "Subject" and respect the parameters
"head_encoding" and "head_charset" from Mail_mime::get().

In case of setting this parameter to "false", "$charset" and
"$language" is not used.

So you can now encode the "name" and "filename" with Q or B encoding
and with the same charset you have defined for the normal headers.

Long filenames are now also folded with the old style: no problems with
e.g. with Outlook Express or Outlook. (see Bug #12429)

I have changed the private method Mail_mime::_encodeHeaders(), to a
public static method Mail_mime::encodeHeaders(). So we can use this (the
same) function from the class Mail_mime and the class Mail_mimePart.

Regards,
Carsten

------------------------------------------------------------------------

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=12411

Search Discussions

  • Alec at Dec 30, 2009 at 12:34 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=12411&edit=1

    ID: 12411
    Updated by: alec@alec.pl
    Reported By: bmdevelopment at gmail dot com
    Summary: Support RFC 2047 standard for non-ascii characters as
    attachment filename.
    Status: Open
    Type: Feature/Change Request
    Package: Mail_Mime
    Operating System: FreeBSD 6.2-RELEASE #0
    Package Version: 1.5.2
    PHP Version: 5.2.4
    -Assigned To:
    +Assigned To: alec
    -Roadmap Versions:
    +Roadmap Versions: 1.6.0RC1
    New Comment:

    -Assigned To:
    +Assigned To: alec
    -Roadmap Versions:
    +Roadmap Versions: 1.6.0RC1



    Previous Comments:
    ------------------------------------------------------------------------

    [2009-12-03 13:41:27] alec

    Updated my bulk patch. Contains fixes for test scripts.

    ------------------------------------------------------------------------

    [2009-12-03 13:39:38] alec

    Added #patch bug:12411;patch:mime_bulk.patch;revision:1259847578;.

    ------------------------------------------------------------------------

    [2009-06-17 11:59:40] alec

    I've attached a bulk patch which addresses issues #12411, #12429,
    #14232, #15320, #14529, #14779. Test script:
    <?php

    include('Mail/mime.php');

    $text = '';
    $crlf = "\n";
    $file = 'empty.txt'; //some empty file
    $files = array(
    'empty.txt',
    'with space.txt',
    'with unicode &#380;&#261;&#347;&#378;&#263;.txt',
    'long name with spaces, very long long long long long very very
    long long.txt',
    'long name with spaces, very long long long long long very very and
    &#380;&#261;&#347;&#378;&#281;&#263;.txt',
    );
    $mime = new Mail_mime($crlf);

    foreach ($files as $name) {
    copy($file, '/tmp/'.$name);
    $mime->addAttachment('/tmp/'.$name, 'text/plain', '', true,
    'base64', 'attachment', 'UTF-8', '', '',
    'quoted-printable');
    }

    $mime->setTXTBody($text);

    echo $mime->getMessage();

    ?>

    And result:

    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    boundary="=_8ea5f688b1cf8f2db7d4f37126f5ac3f"

    --=_8ea5f688b1cf8f2db7d4f37126f5ac3f
    Content-Transfer-Encoding: base64
    Content-Type: text/plain charset=UTF-8;;
    name=empty.txt;
    Content-Disposition: attachment;
    filename=empty.txt;


    --=_8ea5f688b1cf8f2db7d4f37126f5ac3f
    Content-Transfer-Encoding: base64
    Content-Type: text/plain charset=UTF-8;;
    name="with space.txt";
    Content-Disposition: attachment;
    filename="with space.txt";


    --=_8ea5f688b1cf8f2db7d4f37126f5ac3f
    Content-Transfer-Encoding: base64
    Content-Type: text/plain charset=UTF-8;;
    name="=?UTF-8?Q?with_unicode_=C5=BC=C4=85=C5=9B=C5=BA=C4=87.txt?=";
    Content-Disposition: attachment;
    filename*=UTF-8''with%20unicode%20%C5%BC%C4%85%C5%9B%C5%BA%C4%87.txt;


    --=_8ea5f688b1cf8f2db7d4f37126f5ac3f
    Content-Transfer-Encoding: base64
    Content-Type: text/plain charset=UTF-8;;
    name="long name with spaces, very long long long long long very very
    lo.txt";
    Content-Disposition: attachment;

    filename*0*=UTF-8''long%20name%20with%20spaces,%20very%20long%20long%20long;
    filename*1*=%20long%20long%20very%20very%20long%20long.txt;


    --=_8ea5f688b1cf8f2db7d4f37126f5ac3f
    Content-Transfer-Encoding: base64
    Content-Type: text/plain charset=UTF-8;;

    name="=?UTF-8?Q?long_name_with_spaces,_very_long_long_long_long_long_very_v.txt?=";

    Content-Disposition: attachment;

    filename*0*=UTF-8''long%20name%20with%20spaces,%20very%20long%20long%20long;

    filename*1*=%20long%20long%20very%20very%20and%20%C5%BC%C4%85%C5%9B%C5%BA%C4;
    filename*2*=%99%C4%87.txt;


    --=_8ea5f688b1cf8f2db7d4f37126f5ac3f--

    ------------------------------------------------------------------------

    [2009-06-17 11:54:36] alec

    The following patch has been added/updated:

    Patch Name: mime_bulk.patch
    Revision: 1245236075
    URL:
    http://pear.php.net/bugs/patch-display.php?bug=12411&patch=mime_bulk.patch&revision=1245236075&display=1

    ------------------------------------------------------------------------

    [2008-09-29 03:44:47] alec

    mime_param.patch it's my patch for the same issue.

    ------------------------------------------------------------------------

    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=12411

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 3, '09 at 12:41p
activeDec 30, '09 at 12:34p
posts2
users2
websitepear.php.net

2 users in discussion

Alec: 1 post Alec: 1 post

People

Translate

site design / logo © 2022 Grokbase