-
Notifications
You must be signed in to change notification settings - Fork 937
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
mail forgets to escape when passing arguments as hash #1056
Comments
This is because we don't support unencoded UTF-8 yet: >> Mail.new(from: 'Jorg <test@example.com>').smtp_envelope_from
=> "test@example.com"
>> Mail.new(from: 'Jörg <test@example.com>').smtp_envelope_from
=> "Jörg <test@example.com>" The second case is wrong. That's because we couldn't parse the From address, per RFC 5322. We need to encode these fields before using them. Here's a demo showing that this works (since it encodes the UTF-8 chars before parsing!): >> Mail.new(from: Mail::FromField.new('Jörg <test@example.com>').encoded).smtp_envelope_from
=> "test@example.com" We have quite a few open issues regarding UTF-8 support, going back to #39. |
@jeremy Thanks for your fast reply. But the block form does work. It also works when using the setters, for example |
What does |
Same as for you
But when I look at the headers of the email in my mail client, I can see it's properly encoded:
|
Note that's the message From address. The SMTP envelope from address is what's used in the SMTP |
The original issue is fixed by #1103: >> Mail.new(from: 'Jörg <test@example.com>').smtp_envelope_from
=> "test@example.com" |
It seems the mail gem doesn't encode properly when the arguments are passed as a hash to the constructor.
It works when using the block format
It fails when passing the argmuents as a hash to the constructor:
The text was updated successfully, but these errors were encountered: