【问题标题】:Error in SendGrid on Heroku cedar stackHeroku cedar 堆栈上的 SendGrid 错误
【发布时间】:2012-07-10 16:33:58
【问题描述】:

当我尝试通过 heroku cedar 堆栈上的 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获取的

有人有什么建议吗?

【问题讨论】:

  • 您是否通过heroku cli 将 RAILS_ENV 和 RACK_ENV 设置为“暂存”?
  • 验证您已通过heroku config 设置了 SendGrid 凭据
  • 是的,我将 RAILS_ENV 和 RACK_ENV 设置为“暂存”。但我无法发送邮件..

标签: heroku sendgrid cedar


【解决方案1】:

尝试将您的配置从 config/enviornments/staging.rb 移动到 config/initializers/smtp.rb。这样你就知道无论你在什么环境中都配置了 ActionMailer。

您应该在您的环境文件中保留交付特定设置:

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

【讨论】:

  • 非常感谢你的解释,斯威夫特!
  • 没问题,乐于助人!如果您需要更多 SendGrid 帮助,请随时联系我们的支持团队。
猜你喜欢
  • 2011-12-08
  • 2012-04-02
  • 2011-11-22
  • 1970-01-01
  • 2011-12-31
  • 1970-01-01
  • 2011-12-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多