Created
March 16, 2014 19:28
-
-
Save aortbals/9588486 to your computer and use it in GitHub Desktop.
Rails 4 Test SMTP Settings for ActionMailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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