Class: Boppers::Notifier::Sendgrid
- Inherits:
-
Object
- Object
- Boppers::Notifier::Sendgrid
- Defined in:
- lib/boppers/notifier/sendgrid.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #call(title, message, _options) ⇒ Object
-
#initialize(username:, password:, domain:, email:, subscribe: nil) ⇒ Sendgrid
constructor
A new instance of Sendgrid.
Constructor Details
#initialize(username:, password:, domain:, email:, subscribe: nil) ⇒ Sendgrid
Returns a new instance of Sendgrid.
8 9 10 11 12 13 14 15 16 |
# File 'lib/boppers/notifier/sendgrid.rb', line 8 def initialize(username:, password:, domain:, email:, subscribe: nil) require "mail" @username = username @password = password @domain = domain @email = email @subscribe = subscribe end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/boppers/notifier/sendgrid.rb', line 6 def domain @domain end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
6 7 8 |
# File 'lib/boppers/notifier/sendgrid.rb', line 6 def email @email end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/boppers/notifier/sendgrid.rb', line 6 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
6 7 8 |
# File 'lib/boppers/notifier/sendgrid.rb', line 6 def username @username end |
Instance Method Details
#call(title, message, _options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/boppers/notifier/sendgrid.rb', line 18 def call(title, , ) mail = Mail.new mail.delivery_method :smtp, address: "smtp.sendgrid.net", port: 587, user_name: username, password: password, domain: domain, authentication: :plain, enable_starttls_auto: true mail.subject(title) mail.to(email) mail.from("Boppers <noreply@boppers>") mail.part("text/plain") do |part| part.body = end mail.deliver end |