Module: Lipwig::Senders

Defined in:
lib/lipwig/senders.rb

Defined Under Namespace

Classes: Abstract, Postmark, SMTP, SMTPConnection

Constant Summary collapse

UnknownSenderError =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.call(email) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lipwig/senders.rb', line 4

def self.call(email)
  if ENV['LIPWIG_POSTMARK_API_KEY']
    require 'lipwig/senders/postmark'
    Lipwig::Senders::Postmark.call email
  elsif ENV['LIPWIG_SMTP_CONNECTION'] == 'true'
    require 'lipwig/senders/smtp_connection'
    Lipwig::Senders::SMTPConnection.call email
  elsif ENV['LIPWIG_SMTP_ADDRESS']
    require 'lipwig/senders/smtp'
    Lipwig::Senders::SMTP.call email
  else
    raise UnknownSenderError, "Sending protocol could not be determined"
  end
end