我遇到了一个问题,让sendgrid在一个使用authlogic进行身份验证的rails 3.1应用上成功发送电子邮件,该应用正部署在heroku上。我在config/environments/development.rb和production.rb上有以下操作邮件程序配置:
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.default_charset = "utf-8"
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => 587,
:domain => ENV['SENDGRID_DOMAIN'],
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
对于production.rb,上述代码是相同的,除了
config.action_mailer.default_url_options = { :host => [app name in heroku] }
当我运行它的开发模式时,我得到了以下错误报告:
Completed 500 Internal Server Error in 21740ms
Net::SMTPFatalError (550 Cannot receive from specified address notification@[app-domain]: Unauthenticated senders not allowed
):
我现在真的不知道如何设置它来让它工作。有没有人有过在heroku和rails上设置sendgrid的经验?
非常感谢。你们是最棒的!
发布于 2012-01-09 07:24:21
我假设你指的是本地的开发模式?如果是这样的话,我认为SendGrid插件不会让你从Heroku网络之外发送电子邮件(因为他们有独立的账户,他们更希望你使用)。
也就是说,在使用SendGrid附加组件时,您不需要在生产环境中配置邮件,因为它是在您部署应用程序时自动为您配置的。
因此,您可以删除config.action_mailer.smtp_settings
代码,只需在开发中使用默认代码。
发布于 2013-07-16 07:51:56
还要注意的是,如果你在竹子栈上运行你的Heroku应用程序,你不需要在environment.rb文件中配置你的设置,因为Heroku会为你做这些。
然而,在激活应用程序到Heroku之后,你至少需要一次git推送来设置这些设置。我今天早上犯了这个错误,找到了你的帖子。
https://stackoverflow.com/questions/8782274
复制相似问题