diff --git a/config/initializers/mail_extensions.rb b/config/initializers/mail_extensions.rb index a64974d..c109fa7 100644 --- a/config/initializers/mail_extensions.rb +++ b/config/initializers/mail_extensions.rb @@ -115,10 +115,10 @@ module Mail def initialize(parts_list) @parts_list = parts_list @content_disposition_type = "attachment" - parts_list.map do |p| + parts = parts_list.map do |p| p.parts.empty? && p.attachment? ? p : p.attachments - end.flatten.compact.each { |a| self << a } - self + end.flatten.compact + parts.each { |a| self << a } end # rubocop:enable Lint/MissingSuper diff --git a/lib/postal/dkim_header.rb b/lib/postal/dkim_header.rb index 3721e32..36f7094 100644 --- a/lib/postal/dkim_header.rb +++ b/lib/postal/dkim_header.rb @@ -34,14 +34,15 @@ module Postal def normalized_headers [].tap do |new_headers| - headers.select { |h| + dkim_headers = headers.select { |h| h.match(%r{ ^( from|sender|reply-to|subject|date|message-id|to|cc|mime-version|content-type|content-transfer-encoding| resent-to|resent-cc|resent-from|resent-sender|resent-message-id|in-reply-to|references|list-id|list-help| list-owner|list-unsubscribe|list-subscribe|list-post ):}ix) - }.each do |h| + } + dkim_headers.each do |h| new_headers << normalize_header(h) end end