From e22d163a3f4e7f16fda267f7fefa84a845eb8491 Mon Sep 17 00:00:00 2001 From: John Ma Date: Thu, 15 Nov 2018 14:33:59 -0500 Subject: [PATCH] Fixed #305 Added smtp check to rakefile (GRN-42) (#313) * * --- lib/tasks/configuration.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/tasks/configuration.rake b/lib/tasks/configuration.rake index bb15c066..058f3702 100644 --- a/lib/tasks/configuration.rake +++ b/lib/tasks/configuration.rake @@ -28,9 +28,28 @@ namespace :conf do checksum = Digest::SHA1.hexdigest("getMeetings#{ENV['BIGBLUEBUTTON_SECRET']}") test_request("#{ENV['BIGBLUEBUTTON_ENDPOINT']}api/getMeetings?checksum=#{checksum}") passed + + # Tests the checksum on the getMeetings api call + print "Checking SMTP connection" + test_smtp + passed end 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 + + smtp.start(ENV['SMTP_DOMAIN'], ENV['SMTP_USERNAME'], ENV['SMTP_PASSWORD'], + ENV['SMTP_AUTH']) do |s| + s.sendmail('test', ENV['SMTP_USERNAME'], 'notifications@example.com') + end +rescue => exc + failed("Error connecting to SMTP - #{exc}") +end + # takes the full URL including the protocol def test_request(url) uri = URI(url)