Rails,Heroku,ActionMailer,Sendgrid:Heroku Logs表示已发送电子邮件,但未收到电子邮件

时间:2014-12-08 18:05:33

标签: ruby-on-rails email heroku actionmailer sendgrid

这是我第一次尝试使用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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

在SendGrid信息中心中检查您的SendGrid电子邮件活动,确保其已发送:https://sendgrid.com/logs/index