mail icon indicating copy to clipboard operation
mail copied to clipboard

Encoding problem with files that have UTF-8 characters in the name

Open ba opened this issue 16 years ago • 4 comments

When I try to add a file with UTF-8 characters and send it the file doesn't keep the name at my receiving end. I'm using Thunderbird as a mail client when testing.

The offending mime-part: ----==_mimepart_4bbb1dbe3a64b_952241c1f2652436 Date: Tue, 06 Apr 2010 13:40:46 +0200 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit content-disposition: attachment; =?UTF8?B?IGZpbGVuYW1lPSLDpcOkw7YudHh0Ig==?= Content-ID: [email protected]

mööö


----==_mimepart_4bbb1dbe3a64b_952241c1f2652436--

Gem and ruby version: ba@bamse: ~> gem list | grep mail ; ruby -v mail (2.1.5.3, 2.1.3, 1.6.0) ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

Test code: Mail.deliver do self['Return-Path'] = '[email protected]' from '[email protected]' to '[email protected]' subject "Subject with stränge letters" text_part do content_type 'text; charset=utf-8' body '' end

  add_file 'test.txt'
  add_file 'åäö.txt'
end

Files --- test.txt
8711682053384 8711682053391 8711682076956 8711682078219 8711682081035 8711682082926

--- åäö.txt
mööö

ba avatar Apr 06 '10 11:04 ba

Should work in mail 2.2.0, please check for me.

mikel avatar Apr 11 '10 08:04 mikel

I've tried running the ruby code I posted above, but with correct e-mail addresses and absolute paths, and if I have the åäö.txt line there I get the following stacktrace:

/usr/bin/ruby -w /home/ba/mail-test.rb
/usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/parts_list.rb:18: warning: discarding old collect
/usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/field.rb:122:in `send': undefined method `filename' for #<Mail::UnstructuredField:0xb7477a40> (NoMethodError)
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/field.rb:122:in `method_missing'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1846:in `find_attachment'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1703:in `attachment?'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1339:in `add_charset'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1778:in `add_required_fields'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/part.rb:23:in `add_required_fields'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1651:in `ready_to_send!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1649:in `ready_to_send!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1647:in `each'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1647:in `ready_to_send!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1663:in `encoded'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/network/delivery_methods/smtp.rb:91:in `deliver!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:1859:in `do_delivery'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/message.rb:225:in `deliver'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/mail.rb:140:in `deliver'
    from /home/ba/mail-test.rb:9

If I remove the åäö.txt line the mail gets sent but the subject doesn't show the actual subject but the encoded version (Thunderbird 3.0.3): Subject: Subject with =?UTF-8?Q?str=C3=A4nge=?= letters

I've put the files I've been using in a tarball so you can get them in the same encoding as I have, if that would help. http://cell.sanitarium.se/~ba/temp/mikel/mail-test.tar

gaqzi avatar Apr 21 '10 10:04 gaqzi

Please try with Mail 2.2.5 and reopen if this is still an issue.

Mikel

mikel avatar Jun 17 '10 22:06 mikel

Same with 2.2.5 =/:

/usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/field.rb:122:in `send': undefined method `filename' for #<Mail::UnstructuredField:0xb7431cac> (NoMethodError)
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/field.rb:122:in `method_missing'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1849:in `find_attachment'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1706:in `attachment?'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1341:in `add_charset'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1781:in `add_required_fields'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/part.rb:42:in `add_required_fields'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1654:in `ready_to_send!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1652:in `ready_to_send!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1650:in `each'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1650:in `ready_to_send!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1666:in `encoded'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/network/delivery_methods/smtp.rb:91:in `deliver!'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1862:in `do_delivery'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:225:in `deliver'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.5/lib/mail/mail.rb:140:in `deliver'
    from /home/ba/mail-test.rb:30

ba avatar Jun 24 '10 10:06 ba