Class: MetaMailer::Sendgrid

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MetaMailer

#send_secure

Constructor Details

#initialize(api_user, api_key) ⇒ Sendgrid

Returns a new instance of Sendgrid.



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

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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#api_userObject

Returns the value of attribute api_user.



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

def api_user
  @api_user
end

Instance Method Details

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



12
13
14
15
16
# File 'lib/sendgridm.rb', line 12

def send(from, to, subject, html, text)
  from_address = from.split("<")[1].split(">")[0]
  from_name = from.split(" <")[0]
  SendgridToolkit::Mail.new(@api_user, @api_key).send_mail :to => to, :from => from_address, :subject => subject, :text => text
end