Class: Kobot::Mailer
- Inherits:
-
Object
- Object
- Kobot::Mailer
- Defined in:
- lib/kobot/mailer.rb
Overview
Responsible for sending email notifications in SMTP with Gmail
Class Method Summary collapse
-
.send(body) ⇒ Object
Sends email in preconfigured Gmail SMTP credential and to the recipient configured by #Config.gmail_notify_to or self if not configured, with email subject set by #Config.gmail_notify_subject.
Class Method Details
.send(body) ⇒ Object
Sends email in preconfigured Gmail SMTP credential and to the recipient configured by #Config.gmail_notify_to or self if not configured, with email subject set by #Config.gmail_notify_subject.
Whether the email is actually sent or not is dependent on the value of #Config.gmail_notify_enabled, and when it is set to false, the email message will be printed in logging instead.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kobot/mailer.rb', line 18 def send(body) from = Credential.gmail_id to = Config.gmail_notify_to || from subject = Config.gmail_notify_subject = compose(from, to, subject, body) unless Config.gmail_notify_enabled Kobot.logger.info "This email notification would have been sent:\n#{}" return end smtp = Net::SMTP.new( Config.gmail_smtp_address, Config.gmail_smtp_port ) smtp.enable_starttls_auto smtp.start( 'localhost', Credential.gmail_id, Credential.gmail_password, :plain ) do smtp. , from, to end end |