当我尝试通过heroku雪松堆栈上的sendgrid发送电子邮件时, 我收到了以下错误:
ArgumentError (SMTP-AUTH requested but missing user name):
我在/environments/staging.rb中的设置是:
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'myapp' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "587",
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com'
}
我的Sendgrid密码/用户名是根据this page
从Heroku获得的有没有人有任何建议?
答案 0 :(得分:2)
尝试将您的配置从config/enviornments/staging.rb
移至config/initializers/smtp.rb
。这样,无论您处于何种环境,都可以配置ActionMailer。
您应该在环境文件中保留特定于交付的设置:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true