Sha256: 961c7c54e521e45cb8e7059bf3ae7b61368ca420bcf875e59dc6ec6808be275f

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

require 'simple_smtp_test/simple_smtp_test_mailer'

desc 'Tests out the email settings in the current environment'
task :simple_smtp_test, [:to_email_address] => :environment do |t, args|
  raise 'Error: Please provide an email address as a parameter.' if args[:to_email_address].blank?

  puts "Current Mail Server Settings:"
  puts "\n#{ActionMailer::Base.smtp_settings.to_yaml}\nCurrent Rails Environment: #{Rails.env}" if defined?(Rails)
  puts "Preparing to send test message to #{args[:to_email_address]}..."

  mailobj = SimpleSmtpTestMailer.test_email(args[:to_email_address])
  mailobj.raise_delivery_errors = true
  begin
    mailobj.deliver
  rescue Exception => e
    puts "An error has occurred: #{e.message}"
    next
  end

  puts 'Message successfully sent. Please check that the test message was received.'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_smtp_test-1.1 lib/tasks/simple_smtp_test.rake
simple_smtp_test-1.0.0 lib/tasks/simple_smtp_test.rake