Reputation: 814
I have an app that sends email and I configured mandrill in my application.rb file.
config.action_mailer.smtp_settings = {
address: 'smtp.mandrillapp.com',
port: 587,
domain: 'translatr.herokuapp.com',
user_name: ENV["MANDRILL_USERNAME"],
password: ENV["MANDRILL_PASSWORD"],
authentication: 'plain',
enable_starttls_auto: true }
However I don't want to send out mail during development and when testing but I do in production.Do I do this by moving this setting to production.rb?or is there another way to do it?
Upvotes: 0
Views: 749
Reputation: 107117
You want to have this setting in production.rb
only. Because there are other useful settings for the other environments:
In test.rb
you will find something like:
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
This allows you to write specs that check if a mail would have been send on production by checking if ActionMailer::Base.deliveries.size
increased.
And the development environment usually should not sent an email. It just logs into development.rb
what email would be send on production. Also very useful for debugging.
Upvotes: 1
Reputation: 1
Instead of changing the setting in application.rb you can check for current rails environment. If env is production call the mail method.
send_mail if Rails.env.production?
How to tell if rails is in production?
Upvotes: 0
Reputation: 17834
Move your settings to production.rb, then email will be sent in production only
Upvotes: 1