Skip to content

Instantly share code, notes, and snippets.

@aortbals
Created March 16, 2014 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aortbals/9588486 to your computer and use it in GitHub Desktop.
Save aortbals/9588486 to your computer and use it in GitHub Desktop.
Rails 4 Test SMTP Settings for ActionMailer
# Sometimes it's necessary to perform a test of new SMTP settings.
# Should be run from within the rails environment.
# Tested with Rails 4.0.2
ActionMailer::Base.smtp_settings = {
address: ENV['MAILER_ADDRESS'],
domain: ENV['WEB_HOST'],
port: ENV['MAILER_PORT'],
user_name: ENV['MAILER_USER'],
password: ENV['MAILER_PASSWORD'],
authentication: 'login',
enable_starttls_auto: true
}
class TestMailer < ActionMailer::Base
default :from => ENV['MAILER_USER']
def welcome_email
mail(:to => ENV['MAILER_TEST_RECIPIENT'], :subject => "[#{Time.now}] Test Email", :body => "Test mail body from #{Time.now}.")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment