module MailCannon::Adapter::SendgridWeb::InstanceMethods

Public Instance Methods

auth_pair() click to toggle source
# File lib/mailcannon/adapters/sendgrid_web.rb, line 25
def auth_pair
  default_auth = {'username'=>ENV['SENDGRID_USERNAME'],'password'=>ENV['SENDGRID_PASSWORD']}
  begin
    self.auth || self.envelope_bag.auth || default_auth  
  rescue Exception => e
    logger.warn "Unable to read auth config from Envelope or Bag, using default auth options from ENV"
    return default_auth
  end
end
send!() click to toggle source
# File lib/mailcannon/adapters/sendgrid_web.rb, line 6
def send!
  begin
    validate_envelope!
    response = send_multiple_emails
    self.after_sent(successfully_sent?(response))
    return successfully_sent?(response)
  rescue Exception => e
    if e.message == "[\"Permission denied, wrong credentials\"]"
      raise MailCannon::Adapter::AuthException
    else
      raise e
    end
  end
end
send_bulk!() click to toggle source
# File lib/mailcannon/adapters/sendgrid_web.rb, line 21
def send_bulk!
  self.send! # send! does bulk too!
end