Class: MultiMail::Sender::Postmark

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/multi_mail/postmark/sender.rb

Overview

Postmark's outgoing mail sender.

Instance Attribute Summary

Attributes included from Base

#settings, #tracking

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#deliver!(mail) ⇒ Object

Delivers a message via the Postmark API.

Parameters:

  • mail (Mail::Message)

    a message

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/multi_mail/postmark/sender.rb', line 20

def deliver!(mail)
  mail.delivery_method Mail::Postmark, settings

  if settings[:return_response]
    mail.deliver!
  else
    mail.deliver
  end
rescue ::Postmark::InvalidApiKeyError => e
  raise InvalidAPIKey, e.message
rescue ::Postmark::InvalidMessageError => e
  case e.message
  when "Invalid 'From' value."
    raise MissingSender, e.message
  when 'Zero recipients specified'
    raise MissingRecipients, e.message
  when 'Provide either email TextBody or HtmlBody or both.'
    raise MissingBody, e.message
  else
    raise InvalidMessage, e.message
  end
end