Class: MetaMailer::Elasticemail

Inherits:
MetaMailer show all
Defined in:
lib/elasticemailm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MetaMailer

#send_secure

Constructor Details

#initialize(username, api_key) ⇒ Elasticemail

Returns a new instance of Elasticemail.



5
6
7
8
# File 'lib/elasticemailm.rb', line 5

def initialize(username, api_key)
  @username = username
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/elasticemailm.rb', line 3

def api_key
  @api_key
end

#usernameObject

Returns the value of attribute username.



2
3
4
# File 'lib/elasticemailm.rb', line 2

def username
  @username
end

Instance Method Details

#send(from, to, subject, html, text) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/elasticemailm.rb', line 10

def send(from, to, subject, html, text)
  from_address = from.split("<")[1].split(">")[0]
  from_name = from.split(" <")[0]
  uri = URI("https://api.elasticemail.com/mailer/send")
  p = {:username => self.username, :api_key => self.api_key, :from => from_address, :from_name => from_name, :to => to, :subject => subject, :body_html => html, :body_text => text}
  response = send_secure(uri, p)
end