[bbb-greenlight: 19/39] Test email configuration during setup (#1144)




commit f8a4f8519325807462ffbfcf31c92103e9a6ebc8
Author: marklackey <marklackey users noreply github com>
Date:   Wed Sep 23 08:20:49 2020 -0700

    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: Ahmad Farhat <ahmad af farhat gmail com>
    Co-authored-by: Ahmad Farhat <ahmad farhat blindsidenetworks com>

 lib/tasks/configuration.rake | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/lib/tasks/configuration.rake b/lib/tasks/configuration.rake
index d3883ed..827d193 100644
--- a/lib/tasks/configuration.rake
+++ b/lib/tasks/configuration.rake
@@ -39,18 +39,8 @@ namespace :conf do
 end
 
 def test_smtp
-  smtp = Net::SMTP.new(ENV['SMTP_SERVER'], ENV['SMTP_PORT'])
-  if ENV['SMTP_STARTTLS_AUTO']
-    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
+  TestMailer.test_email(ENV.fetch('SMTP_SENDER', 'notifications example com'),
+                        ENV.fetch('SMTP_TEST_RECIPIENT', 'notifications example com')).deliver
 rescue => e
   failed("Error connecting to SMTP - #{e}")
 end
@@ -83,3 +73,13 @@ end
 def passed
   print(": Passed\n")
 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]