Class: ThecoreBackendCommons::SmtpTester
- Inherits:
-
Object
- Object
- ThecoreBackendCommons::SmtpTester
- Defined in:
- lib/thecore_backend_commons/smtp_tester.rb
Overview
Sends a test email using the SMTP settings from ThecoreSettings. Usable from the Rails console or via the rake task.
From rails console:
ThecoreBackendCommons::SmtpTester.call("you@example.com")
From the shell:
rails thecore_backend_commons:smtp:test[you@example.com]
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(recipient = nil) ⇒ SmtpTester
constructor
A new instance of SmtpTester.
Constructor Details
#initialize(recipient = nil) ⇒ SmtpTester
Returns a new instance of SmtpTester.
17 18 19 20 |
# File 'lib/thecore_backend_commons/smtp_tester.rb', line 17 def initialize(recipient = nil) @recipient = recipient.presence || ThecoreSettings::Setting.find_by(ns: :mytask, key: :default_email)&.raw end |
Class Method Details
.call(recipient = nil) ⇒ Object
13 14 15 |
# File 'lib/thecore_backend_commons/smtp_tester.rb', line 13 def self.call(recipient = nil) new(recipient).call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 |
# File 'lib/thecore_backend_commons/smtp_tester.rb', line 22 def call validate! print_settings send_mail end |