【发布时间】:2015-02-06 11:15:13
【问题描述】:
这是我第一次尝试使用 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
【问题讨论】:
-
有没有可能是异步的(在后台作业中)?
-
我不太确定这意味着什么,或者我什至不能检查它?
-
哪个控制器#action 发送了电子邮件?你在用设计吗?安装了任何 bg 工作宝石吗? (delayed_job, Sidekiq, resque)
标签: ruby-on-rails email heroku actionmailer sendgrid