Skip to content

Commit

Permalink
Pass-thru invalid emails (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields authored Jul 24, 2022
1 parent 7b0a5c0 commit 7ac27a3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ Style/IfUnlessModifier:

Style/RaiseArgs:
EnforcedStyle: compact

Style/StringLiterals:
Exclude:
- 'spec/**/*.rb'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 1.0.5

- Pass-thru invalid email addresses.

### 1.0.4

- Fix missing method error related to message headers.
Expand Down
10 changes: 8 additions & 2 deletions lib/mail/ses/options_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ def slice_hash(hash, *keys)

def extract_value(key)
value = @message.header[key]
return unless value.respond_to?(:formatted)
return unless value

value.formatted&.map { |v| encode(v) }
if value.respond_to?(:formatted)
value.formatted
elsif value.respond_to?(:unparsed_value)
Array(value.unparsed_value)
else
[]
end&.map { |v| encode(v) }
end

def encode(value)
Expand Down
2 changes: 1 addition & 1 deletion lib/mail/ses/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Mail
class SES
VERSION = '1.0.4'
VERSION = '1.0.5'
end
end
27 changes: 27 additions & 0 deletions spec/options_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,32 @@

it { expect(subject).to eq(exp) }
end

context 'when addresses are invalid' do
let(:mail) do
Mail.new do
from '了承ございます <[email protected]'
reply_to ['テスト@test.com', 'A@b@[email protected]', '[email protected]', '[email protected]']
to ['mailto:[email protected]', '']
cc ['<[email protected]']
body 'This is the body'
end
end

let(:exp) do
{
from_email_address: '=?UTF-8?B?5LqG5om/44GU44GW44GE44G+44GZ?= <[email protected]',
reply_to_addresses: ["=?UTF-8?B?44OG44K544OIQHRlc3QuY29t?=", "A@b@[email protected]", "[email protected]", "[email protected]"],
destination: {
to_addresses: ['mailto:[email protected]', ''],
cc_addresses: ['<[email protected]'],
bcc_addresses: []
},
content: { raw: { data: 'Fixed message body' } }
}
end

it { expect(subject).to eq(exp) }
end
end
end

0 comments on commit 7ac27a3

Please sign in to comment.