【发布时间】:2018-02-21 04:01:27
【问题描述】:
我正在尝试从我的 Rails 5 应用程序创建一封电子邮件,并且我想为每个环境设置“发件人:”地址。所以我用这个内容创建了 config/initializers/mailer_config.rb
if defined?(Rails)
case Rails.env
when "production"
RAILS_FROM_EMAIL = "no-reply@me.no-ip.com"
when "test"
RAILS_FROM_EMAIL = "no-reply@me.no-ip.com"
when "development"
RAILS_FROM_EMAIL = "no-reply@me.no-ip.com"
end
end
这是我的邮件类,app/mailers/user_notifier.rb
class UserNotifier < ActionMailer::Base
default :from => '#{RAILS_FROM_EMAIL}'
...
end
但是当我去测试我的邮件时,发件人地址似乎没有被取走。它显示为
From:
#{RAILS_FROM_EMAIL}
我还需要配置什么才能识别我的“发件人”地址?
【问题讨论】:
标签: ruby-on-rails email environment-variables ruby-on-rails-5 mailer