Class: Mailgun::Sendmail
- Inherits:
-
Object
- Object
- Mailgun::Sendmail
- Defined in:
- lib/mailgun-sendmail.rb,
lib/mailgun-sendmail/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(api_key, domain) ⇒ Sendmail
constructor
A new instance of Sendmail.
- #mail(mail_from, mail_to, title, body, attachment = nil) ⇒ Object
Constructor Details
#initialize(api_key, domain) ⇒ Sendmail
Returns a new instance of Sendmail.
20 21 22 23 |
# File 'lib/mailgun-sendmail.rb', line 20 def initialize(api_key, domain) @api_key = api_key @domain = domain end |
Class Method Details
.mail(*args) ⇒ Object
14 15 16 17 18 |
# File 'lib/mailgun-sendmail.rb', line 14 def self.mail(*args) config = setup sendmail = Sendmail.new(config['api_key'], config['domain']) sendmail.mail(*args) end |
.setup ⇒ Object
7 8 9 10 11 12 |
# File 'lib/mailgun-sendmail.rb', line 7 def self.setup Pit.get("mailgun-sendmail", :require => { "api_key" => "Your mailgun API Key", "domain" => "Your mailgun domain", }) end |
Instance Method Details
#mail(mail_from, mail_to, title, body, attachment = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mailgun-sendmail.rb', line 25 def mail(mail_from, mail_to, title, body, =nil) api_url = "https://api:#@api_key@api.mailgun.net/v2/#@domain/messages" = { :from => mail_from, :to => mail_to, :subject => title, :text => body, } [:attachment] = File.new(, "rb") if RestClient.post(api_url, ) end |