Mailer Heroku+sendgrid 发邮件失败的问题

richard020389 · November 01, 2012 · Last by hong_xin replied at January 07, 2017 · 9825 hits

本地启动 server 在 develop 模式下确认可以发邮件,但是到了 product 模式下就是不行 heroku logs 里面是 Sent mail to [email protected] (3059ms) Completed 500 Internal Server Error in 3241ms Errno::ECONNREFUSED (Connection refused - connect(2)):

config 是按网上写的 config\initializers\mail.rb 文件(user_name 和 password 是 heroku config 里面显示的两个环境变量的值) ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => *****, :password => *****, :domain => 'heroku.com' } ActionMailer::Base.delivery_method = :smtp

不知道是哪里设置的不对,希望有经验的朋友指点~

stackoverflow 上看到某人的经验之谈 http://stackoverflow.com/questions/6019083/setting-up-devise-sendgrid-on-heroku 于是自己搞定了。。。

需要在 config 里面加上 config.mailer_sender = "[email protected]" 我的环境下貌似这个设置是必须的,但是 sendgrid 的文档上没有看到相关叙述。。。坑爹啊。。。

踩到坑 +1...

config/initializers/devise.rb :

config.mailer_sender = ENV['SENDGRID_USERNAME']

無奈 R

You need to Sign in before reply, if you don't have an account, please Sign up first.