From 7ac27a335fce058bfb6297bbd2e5f55b9d932823 Mon Sep 17 00:00:00 2001 From: Johnny Shields Date: Sun, 24 Jul 2022 21:55:23 +0900 Subject: [PATCH] Pass-thru invalid emails (#8) --- .rubocop.yml | 4 ++++ CHANGELOG.md | 4 ++++ lib/mail/ses/options_builder.rb | 10 ++++++++-- lib/mail/ses/version.rb | 2 +- spec/options_builder_spec.rb | 27 +++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2e5263b..19620f7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -30,3 +30,7 @@ Style/IfUnlessModifier: Style/RaiseArgs: EnforcedStyle: compact + +Style/StringLiterals: + Exclude: + - 'spec/**/*.rb' diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bc82f..f2d7b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 1.0.5 + +- Pass-thru invalid email addresses. + ### 1.0.4 - Fix missing method error related to message headers. diff --git a/lib/mail/ses/options_builder.rb b/lib/mail/ses/options_builder.rb index 295daed..1bde316 100644 --- a/lib/mail/ses/options_builder.rb +++ b/lib/mail/ses/options_builder.rb @@ -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) diff --git a/lib/mail/ses/version.rb b/lib/mail/ses/version.rb index 23de8cb..ed842a8 100644 --- a/lib/mail/ses/version.rb +++ b/lib/mail/ses/version.rb @@ -2,6 +2,6 @@ module Mail class SES - VERSION = '1.0.4' + VERSION = '1.0.5' end end diff --git a/spec/options_builder_spec.rb b/spec/options_builder_spec.rb index 2c91802..e8451bc 100644 --- a/spec/options_builder_spec.rb +++ b/spec/options_builder_spec.rb @@ -129,5 +129,32 @@ it { expect(subject).to eq(exp) } end + + context 'when addresses are invalid' do + let(:mail) do + Mail.new do + from '了承ございます