Skip to content
Snippets Groups Projects
Unverified Commit f8a4f851 authored by marklackey's avatar marklackey Committed by GitHub
Browse files

Test email configuration during setup (#1144)


* create proper test message and use correct env var for from address. designed to work with sandboxed AWS ses

* use actionmailer in configuration test rake task

* remove mailfactory gem

* tidy up Gemfile and gem lock

* fix rubocop issues

* Update configuration.rake

Co-authored-by: default avatarAhmad Farhat <ahmad.af.farhat@gmail.com>
Co-authored-by: default avatarAhmad Farhat <ahmad.farhat@blindsidenetworks.com>
parent b89cbfad
No related branches found
No related tags found
No related merge requests found
...@@ -39,18 +39,8 @@ namespace :conf do ...@@ -39,18 +39,8 @@ namespace :conf do
end end
def test_smtp def test_smtp
smtp = Net::SMTP.new(ENV['SMTP_SERVER'], ENV['SMTP_PORT']) TestMailer.test_email(ENV.fetch('SMTP_SENDER', 'notifications@example.com'),
if ENV['SMTP_STARTTLS_AUTO'] ENV.fetch('SMTP_TEST_RECIPIENT', 'notifications@example.com')).deliver
smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto)
end
user = ENV['SMTP_USERNAME'].presence || nil
password = ENV['SMTP_PASSWORD'].presence || nil
authtype = ENV['SMTP_AUTH'].present? && ENV['SMTP_AUTH'] != "none" ? ENV['SMTP_AUTH'] : nil
smtp.start(ENV['SMTP_DOMAIN'], user, password, authtype) do |s|
s.sendmail('test', ENV['SMTP_USERNAME'], ENV.fetch('SMTP_TEST_RECIPIENT', 'notifications@example.com'))
end
rescue => e rescue => e
failed("Error connecting to SMTP - #{e}") failed("Error connecting to SMTP - #{e}")
end end
...@@ -83,3 +73,13 @@ end ...@@ -83,3 +73,13 @@ end
def passed def passed
print(": Passed\n") print(": Passed\n")
end end
class TestMailer < ActionMailer::Base
def test_email(sender, recipient)
mail(to: recipient,
from: sender,
subject: "Greenlight Email Test",
body: "This is what people with plain text mail readers will see.",
content_type: "text/plain",)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment