Class: MetaMailer::Jangomail

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MetaMailer

#send_secure

Constructor Details

#initialize(username, password) ⇒ Jangomail

Returns a new instance of Jangomail.



7
8
9
10
# File 'lib/jangomailm.rb', line 7

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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/jangomailm.rb', line 4

def username
  @username
end

Instance Method Details

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



12
13
14
15
16
17
18
# File 'lib/jangomailm.rb', line 12

def send(from, to, subject, html, text)
  uri = URI("http://api.jangomail.com/api.asmx/SendTransactionalEmail")
  from_address = from.split("<")[1].split(">")[0]
  from_name = from.split(" <")[0]
  p = {:Username => @username, :Password => @password, :FromEmail => from_address, :FromName => from_name, :ToEmailAddress => to, :Subject => subject, :MessagePlain => text, :MessageHTML => html, :Options => ""}
  response = Net::HTTP.post_form(uri, p)
end