We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We are seeing errors in production when sending email via Mailtrap where the from address includes brackets. For example
from
mail(from: "foo (bar) <[email protected]>")
Leads to this
I tried writing a failing test, I couldn't get it to crash, but it does fail:
diff --git a/spec/mailtrap/mail_spec.rb b/spec/mailtrap/mail_spec.rb index 6bd5f88..301d545 100644 --- a/spec/mailtrap/mail_spec.rb +++ b/spec/mailtrap/mail_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Mailtrap::Mail do let(:message) { Mail::Message.new(**message_params) } let(:message_params) do { - from: 'Mailtrap Test <[email protected]>', + from: 'Mailtrap (Test) <[email protected]>', to: 'To 1 <[email protected]>, [email protected]', cc: '[email protected], Cc 2 <[email protected]>', bcc: '[email protected], [email protected]', @@ -23,7 +23,7 @@ RSpec.describe Mailtrap::Mail do } end - its(:from) { is_expected.to eq({ name: 'Mailtrap Test', email: '[email protected]' }) } + its(:from) { is_expected.to eq({ name: 'Mailtrap (Test)', email: '[email protected]' }) } its(:to) { is_expected.to eq([{ name: 'To 1', email: '[email protected]' }, { email: '[email protected]' }]) } its(:cc) { is_expected.to eq([{ email: '[email protected]' }, { name: 'Cc 2', email: '[email protected]' }]) } its(:bcc) { is_expected.to eq([{ email: '[email protected]' }, { email: '[email protected]' }]) }
So I suspect there's something wrong in the gem here, and maybe the test just isn't accurately replicating how Action Mailer works.
The text was updated successfully, but these errors were encountered:
You should quote the display name if it contains parenthesis, they are a special character according to the RFC; the relevant part is:
display-name = phrase phrase = 1*word / obs-phrase obs-phrase = word *(word / "." / CFWS) word = atom / quoted-string atom = [CFWS] 1*atext [CFWS] atext = ALPHA / DIGIT / ; Printable US-ASCII "!" / "#" / ; characters not including "$" / "%" / ; specials. Used for atoms. "&" / "'" / "*" / "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~"
Or you can use the email+name form, and I'm pretty sure we will quote it for you:
{ email: '[email protected]', name: 'Mailtrap (Test)' }
But I admit that stripping the parens is sketchy, will look into it.
Sorry, something went wrong.
No branches or pull requests
We are seeing errors in production when sending email via Mailtrap where the
from
address includes brackets. For exampleLeads to this
I tried writing a failing test, I couldn't get it to crash, but it does fail:
So I suspect there's something wrong in the gem here, and maybe the test just isn't accurately replicating how Action Mailer works.
The text was updated successfully, but these errors were encountered: