简体   繁体   中英

Development and production configurations for Rails mailer

For deliverability reasons, I installed SPF records and other types of authentication to make sure production emails aren't flagged as spam. The side-effect is that when I run tests from my localhost they don't work. Is there a "Rails Way" to have development vs. production credentials for a mailer? It seems like I could build my own logic based on the Rails.env variable, but I don't want to reinvent the wheel if there is already support for this.

The "Rails way" is to put shared configuration in config/application.rb and environment-specific overrides in config/environments/<env>.rb .

In your case I would put your SPF stuff in config/environments/production.rb .

See this link for more information on configuring ActionMailer: http://guides.rubyonrails.org/action_mailer_basics.html#example-action-mailer-configuration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM