Class: LetsencryptWebfaction::Emailer
- Inherits:
-
Object
- Object
- LetsencryptWebfaction::Emailer
- Defined in:
- lib/letsencrypt_webfaction/emailer.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- SUBJECT_MESSAGE =
'New certificate installation'.freeze
Instance Method Summary collapse
-
#initialize(instructions, support_email: '', account_email: '', notification_email: '', email_configuration: {}) ⇒ Emailer
constructor
A new instance of Emailer.
- #send! ⇒ Object
- #send_to_account! ⇒ Object
- #send_to_support! ⇒ Object
Constructor Details
#initialize(instructions, support_email: '', account_email: '', notification_email: '', email_configuration: {}) ⇒ Emailer
Returns a new instance of Emailer.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/letsencrypt_webfaction/emailer.rb', line 7 def initialize(instructions, support_email: '', account_email: '', notification_email: '', email_configuration: {}) @instructions = instructions raise Error, 'Missing account_email' if account_email == '' || account_email.nil? raise Error, 'Missing notification_email' if notification_email == '' || notification_email.nil? @support_email = support_email @account_email = account_email @notification_email = notification_email Pony. = email_configuration end |
Instance Method Details
#send! ⇒ Object
20 21 22 23 |
# File 'lib/letsencrypt_webfaction/emailer.rb', line 20 def send! send_to_support! send_to_account! end |
#send_to_account! ⇒ Object
30 31 32 |
# File 'lib/letsencrypt_webfaction/emailer.rb', line 30 def send_to_account! Pony.mail(to: @notification_email, from: @notification_email, subject: SUBJECT_MESSAGE, body: @instructions.(support_email: @support_email != '')) end |
#send_to_support! ⇒ Object
25 26 27 28 |
# File 'lib/letsencrypt_webfaction/emailer.rb', line 25 def send_to_support! return if @support_email.nil? || @support_email == '' Pony.mail(to: @support_email, from: @account_email, subject: SUBJECT_MESSAGE, body: @instructions.instructions) end |