Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header encoding when Initializing from a hash #528

Closed
flop opened this issue Mar 28, 2013 · 1 comment
Closed

Header encoding when Initializing from a hash #528

flop opened this issue Mar 28, 2013 · 1 comment

Comments

@flop
Copy link

flop commented Mar 28, 2013

I'm not sure if I'm doing something wrong or if it's a problem with the gem. When I'm trying to create an email with at least 2 recipient with utf8 characters from a Hash I get different encoding for the To header. And doing so, the smtp refuse to send my email with "501 5.1.3 Bad recipient address syntax".

Classical Init (works great):

1.9.3p374 :001 > m = Mail::Message.new
#<Mail::Message:19456400, Multipart: false, Headers: >
1.9.3p374 :002 > m.to = ['äää <aaa@test.com>', 'äbä <aba@test.com>']
[
    [0] "äää <aaa@test.com>",
    [1] "äbä <aba@test.com>"
]
1.9.3p374 :003 > m[:to].encoded
"To: =?UTF-8?B?w6TDpMOk?= <aaa@test.com>, \r\n =?UTF-8?B?w6Riw6Q=?= <aba@test.com>\r\n"

Init from a hash (rejected by smtp server with "501 5.1.3 Bad recipient address syntax"):

1.9.3p374 :004 > m2 = Mail::Message.new({:to => ['äää <aaa@test.com>', 'äbä <aba@test.com>']})
#<Mail::Message:20692240, Multipart: false, Headers: <to: äää <aaa@test.com>, äbä <aba@test.com>>>
1.9.3p374 :005 > m2[:to].encoded
"to: =?UTF-8?Q?=C3=A4=C3=A4=C3=A4_<aaa@test.com>,_=C3=A4b=C3=A4_<aba@t?=\r\n =?UTF-8?Q?est.com>?=\r\n"

I was expecting the same behaviour when creating an email from hash but it's not. Is this a bug or I should not use the initialize with a hash ?

@jeremy
Copy link
Collaborator

jeremy commented May 17, 2017

Fixed by #1103. This is due to having a To address that couldn't be parsed, leading to encoding the entire address and passing that through as the SMTP sender, leading to the error above.

@jeremy jeremy closed this as completed May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants