Error in SendGrid on Heroku cedar stack

六眼飞鱼酱① 提交于 2020-01-06 03:30:09

问题


when I try to send an email via sendgrid on heroku cedar stack, I got an following error :

ArgumentError (SMTP-AUTH requested but missing user name):

my settings in /environments/staging.rb are :

  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'
  }

My Sendgrid password/username are obtained from Heroku according to this page

Does anyone have any suggestion ?


回答1:


Try moving your config from config/enviornments/staging.rb into config/initializers/smtp.rb. That way you know ActionMailer is configured regardless of the environment you're in.

You should keep delivery specific setting in your environment files:

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true  


来源:https://stackoverflow.com/questions/11426202/error-in-sendgrid-on-heroku-cedar-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!