diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-11-05 14:21:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-05 14:21:27 -0500 |
commit | 152a442b1902050265ddcef56f5506b3bfbb12e4 (patch) | |
tree | bd365d76299e978a6e974a64f5ff3d47f0614514 /app/models/action_mailbox | |
parent | c474daefb18e9bab96f6f0bb0bb30dfc00058cb3 (diff) | |
parent | ac7fd0e56886eb134554789e014d2736b95d7042 (diff) | |
download | rails-152a442b1902050265ddcef56f5506b3bfbb12e4.tar.gz rails-152a442b1902050265ddcef56f5506b3bfbb12e4.tar.bz2 rails-152a442b1902050265ddcef56f5506b3bfbb12e4.zip |
Merge pull request #1 from basecamp/ingresses
Accept inbound emails from a variety of ingresses
Diffstat (limited to 'app/models/action_mailbox')
-rw-r--r-- | app/models/action_mailbox/inbound_email/message_id.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/action_mailbox/inbound_email/message_id.rb b/app/models/action_mailbox/inbound_email/message_id.rb index a1ec5c0437..5cfcadaba1 100644 --- a/app/models/action_mailbox/inbound_email/message_id.rb +++ b/app/models/action_mailbox/inbound_email/message_id.rb @@ -6,14 +6,16 @@ module ActionMailbox::InboundEmail::MessageId end module ClassMethods - def create_and_extract_message_id!(raw_email, **options) - create! raw_email: raw_email, message_id: extract_message_id(raw_email), **options + def create_and_extract_message_id!(source, **options) + create! message_id: extract_message_id(source), **options do |inbound_email| + inbound_email.raw_email.attach io: StringIO.new(source), filename: "message.eml", content_type: "message/rfc822" + end end private - def extract_message_id(raw_email) - mail_from_source(raw_email.read).message_id - rescue + def extract_message_id(source) + mail_from_source(source).message_id + rescue => e # FIXME: Add logging with "Couldn't extract Message ID, so will generating a new random ID instead" end end |