Class: Sunabamail::DeliveryMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/sunabamail/delivery_method.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DeliveryMethod

Returns a new instance of DeliveryMethod.



5
6
# File 'lib/sunabamail/delivery_method.rb', line 5

def initialize(options = {})
end

Instance Method Details

#deliver!(mail) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/sunabamail/delivery_method.rb', line 8

def deliver!(mail)
  subject = mail.subject
  created_at = mail.date || Time.zone.now
  updated_at = created_at
  addresses = %i[bcc cc from reply_to sender to].to_h { [ _1, mail[_1].to_s.presence ] }

  message = Sunabamail::Message.new(**addresses, subject:, created_at:, updated_at:)
  message.build_raw(encoded: mail.encoded)
  message.save!
end