Class: Howlr::Deliverers::Email

Inherits:
Base
  • Object
show all
Defined in:
lib/howlr/deliverers.rb

Defined Under Namespace

Classes: Mailer

Class Method Summary collapse

Class Method Details

.deliver(message, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/howlr/deliverers.rb', line 26

def self.deliver(message, options = {})
  recipients = []
  message.recipients.each do |r|
    if $OVERRIDE_RECIPIENT.blank? # set using --override-recipient CLI option
      recipients << (r.respond_to?(:address) ? r.address : r)
    else
      recipients << $OVERRIDE_RECIPIENT
    end
  end
  
  Mailer.raise_delivery_errors = true
  
  begin
    Mailer.deliver_message(
      message.subject,
      recipients,
      message.from,
      message.body,
      message.content_type
    )
    return true
  rescue => e
    message.delivery_errors << e
    return false
  end
end