Skip to content

UTF8 in attachment filename is not encoded #75

@tumapav

Description

@tumapav

Version: 3.1.4

Bug Description

If the attachment file name contains UTF8 characters, the header is not RFC 2047 encoded, which causes email to rely on support of SMTPUTF8 extension, making the email undeliverable to destinations servers that don't support it (gmail supports it, but e.g. email.cz does not).

Steps To Reproduce

$mail = new Nette\Mail\Message;
$mail->setFrom('John <[email protected]>')
        ->addTo('[email protected]')
        ->setSubject('Kůň v příloze')
        ->setBody("Test")
        ->addAttachment("kůň.txt", "test");

die($mail->generateMessage());

See resulting Content-Disposition header:

Content-Disposition: attachment; filename="kůň.txt"

Expected Behavior

Content-Disposition: attachment; filename="=?UTF-8?B?a8WvxYgudHh0?="

Possible Solution

This worked in the previous version, the bug was introduced with this change 6f33373 which fixed #24, in this change, call to encodeHeader() has been removed. This call should be probably returned, but I'm not sure how exactly in order to not introduce back the issue #24.

I know a workaround is not to use utf8 in attachment file name with e.g. Strings::toAscii($filename), but as long as the encoding works well with other headers like Subject or From, I don't see a reason for this header to be an exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions