如何在环境配置文件

时间:2016-02-27 00:49:04

标签: ruby-on-rails actionmailer

我的数据库中存储了action_mailer.smtp_settings的设置。显然我无法将它们加载到我的production.rb或development.rb环境配置文件中。有什么办法可以在我的ApplicationMailer类中设置它们吗?

1 个答案:

答案 0 :(得分:0)

是的!你可以在你的邮件中做这样的事情:

delivery_options = { user_name: company.smtp_user,
                     password: company.smtp_password,
                     address: company.smtp_host }
mail(to: @user.email,
     subject: "Please see the Terms and Conditions attached",
     delivery_method_options: delivery_options)

http://edgeguides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-dynamic-delivery-options

希望它有所帮助!