Rails、Heroku、ActionMailer、Sendgrid:Heroku日志显示已发送电子邮件,但未收到任何电子邮件。

3

这是我第一次尝试使用Heroku发送电子邮件,我非常困惑如何配置所有内容。我已经看了好几个小时了,但仍然无法弄清楚为什么我没有收到电子邮件。我已经在网上到处寻找,但似乎找不到我的配置有什么问题。

如果有人能给予帮助,我将不胜感激。

我的product.rb文件:

config.action_mailer.default_url_options = { :host => 'acebros.herokuapp.com' }

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
  address: 'smtp.sendgrid.net',
  port: '587',
  authentication: "plain",
  user_name: ENV['SENDGRID_USERNAME'],
  password: ENV['SENDGRID_PASSWORD'],
  :domain         => 'heroku.com',
  :enable_starttls_auto => true
}
config.action_mailer.delivery_method = :smtp

一个邮件发送器示例:
default from: "acebrosdev@gmail.com"
def quote_email(user, quote)
    @customer = user
    @quote = quote
    @url = 'acebros.herokuapp.com/' + quote_status_path(@quote)
    #attachments['quote.pdf'] = WickedPdf.new.pdf_from_string(
                           #render_to_string(:pdf => 'quote', :template =>
                           #'quotes/quote_attachment.html.erb')
                           #)
    mail(to: @customer.email, subject: "Quote ID: ##{@quote.id}")
end

最后,这是我的Heroku日志:

2014-12-08T17:56:38.121051+00:00 app[web.1]: Started POST "/quotes/5/done" for 129.31.193.143 at      2014-12-08 17:56:38 +0000
2014-12-08T17:56:38.241873+00:00 app[web.1]:   Rendered quote_mailer/quote_email.text.erb (0.4ms)
2014-12-08T17:56:39.684236+00:00 app[web.1]: Redirected to http://acebros.herokuapp.com/quotes/5
2014-12-08T17:56:39.683035+00:00 app[web.1]: Sent mail to annikamonari@gmail.com (1093.2ms)
2014-12-08T17:56:39.683029+00:00 app[web.1]: 
2014-12-08T17:56:39.684436+00:00 app[web.1]: Completed 302 Found in 1560ms (ActiveRecord: 26.9ms)
2014-12-08T17:56:39.692999+00:00 heroku[router]: at=info method=POST path="/quotes/5/done"  host=acebros.herokuapp.com request_id=0c19e839-1d20-43ee-9e27-8ba657eb3637 fwd="129.31.193.143" dyno=web.1 connect=2ms service=1572ms status=302 bytes=1246
2014-12-08T17:56:42.352091+00:00 app[web.1]: Processing by QuotesController#show as HTML

有没有可能是异步的(在后台作业中)? - Mark Swardstrom
我不太确定那是什么意思,或者我该如何检查? - annikam
发送电子邮件的控制器#操作是什么?您是否使用Devise?安装了任何后台作业宝石吗?(delayed_job,Sidekiq,resque) - Mark Swardstrom
2个回答

1
我终于找到了解决方法。他们暂时禁用了我的sendgrid帐户,并且由heroku config自动生成的电子邮件与我的电子邮件不匹配,因此我没有收到它。不得不联系客户支持。无论如何感谢您的帮助。

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接