简体   繁体   English

邮件程序的Rails配置

[英]Rails configurations with mailers

i am having troubles using the rails configuration adress in the mailer. 我在使用邮件程序中的rails配置地址时遇到了麻烦。 I use the newest ruby and rails versions and want to add a mail adress from the configurations. 我使用最新的ruby和rails版本,并希望从配置中添加邮件地址。 i am using the folling code in the mailer file: 我在邮件文件中使用以下代码:

 mail(to: Rails.configuration.email.sales , subject: 'Contact through jobs page')

on the development.rb page i am using this code: 在development.rb页面上,我正在使用以下代码:

  config.email.sales = 'sales@domain.com'

i dont understand why this isnt working. 我不明白为什么这不起作用。 Would be great if you can help me. 如果您能帮助我,那就太好了。 Thanks 谢谢

Since you add that into development.rb that, you can try with something like: 由于您将其添加到development.rb中,因此可以尝试以下操作:

mail(to: YourApplication::Application.config.email.sales,, subject: 'Contact through jobs page')

That will return 'sales@domain.com', if you have that config.email.sales properly working :). 如果您的config.email.sales正常工作,则将返回“ sales@domain.com” :)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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