Class: MetaMailer::Mailgun

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MetaMailer

#send_secure

Constructor Details

#initialize(username, api_key) ⇒ Mailgun

Returns a new instance of Mailgun.



8
9
10
11
# File 'lib/mailgunm.rb', line 8

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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

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



13
14
15
16
17
18
19
20
21
22
# File 'lib/mailgunm.rb', line 13

def send(from, to, subject, html, text)
  data = Multimap.new
	data[:from] = from
	data[:to] = to
	data[:subject] = subject
	data[:text] = text
	data[:html] = html
	RestClient.post "https://api:#{@api_key}"\
	"@api.mailgun.net/v2/#{@username}.mailgun.org/messages", data
end