Ruby on rails 3 Heroku部署的应用程序存在Sendgrid错误,没有日志信息
我的应用程序有一个联系人页面,用户可以在其中输入姓名/电子邮件/主题/内容并向我发送消息。我正在使用Sendgrid插件到heroku,我认为我几乎做得都对。我把这个放在口袋里了 电子邮件\u controller.rbRuby on rails 3 Heroku部署的应用程序存在Sendgrid错误,没有日志信息,ruby-on-rails-3,heroku,sendgrid,Ruby On Rails 3,Heroku,Sendgrid,我的应用程序有一个联系人页面,用户可以在其中输入姓名/电子邮件/主题/内容并向我发送消息。我正在使用Sendgrid插件到heroku,我认为我几乎做得都对。我把这个放在口袋里了 电子邮件\u controller.rb if @email.save ContactMailer.contact_message(@email).deliver flash.now[:success] = "Your email has sent! I'll try to get back to you sh
if @email.save
ContactMailer.contact_message(@email).deliver
flash.now[:success] = "Your email has sent! I'll try to get back to you shortly."
render :new
else
flash.now[:error] = "Please correct the highlighted errors and try again."
render :new
end
(这里的想法是记录每封电子邮件,并将其发送给我)
My config/initializers/mail.rb
# SendGrid Settings
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:enable_starttls_auto => true,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'myappname.com'
}
ActionMailer::Base.delivery_method = :smtp
然后,为了更好的衡量,在sendgrid支持问题中遵循其他人的做法。config/environments/production.rb:
config.action_mailer.default_url_options = { :host => 'myappname.com' }
我的联系人_email.html.erb:
class Contact < ActionMailer::Base
default from: "unimportant@example.com"
def contact_message(email)
@name = email.name
@address = email.address
@subject = email.subject
@content = email.content
mail(:to => ENV['EMAIL_ADDRESS'], :subject => @subject)
end
end
当我推到heroku并试图给自己发一封电子邮件时,它会给我一个“很抱歉,出了什么问题”的死亡屏幕,而日志(在我看来)完全没有用
这是我上次给heroku发邮件时的日志。知道可能出了什么问题吗
2013-02-03T20:34:18+00:00 heroku[router]: at=info method=GET path=/ host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=7ms service=201ms status=304 bytes=0
2013-02-03T20:34:18+00:00 heroku[router]: at=info method=GET path=/assets/application-cd9c41b78562d03bb04bcaaa585b31e8.js host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=1ms service=11ms status=200 bytes=125507
2013-02-03T20:34:19+00:00 heroku[router]: at=info method=GET path=/assets/pig3-b2d5155bd2811a87cafec6a447459580.png host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=1ms service=4ms status=200 bytes=3010
2013-02-03T20:34:19+00:00 heroku[router]: at=info method=GET path=/assets/github-e8c3b3f49b0cc737afe9b3cd6e9ab159.png host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=1ms service=4ms status=200 bytes=3687
2013-02-03T20:34:19+00:00 heroku[router]: at=info method=GET path=/assets/odesk2-38dadc2e6b0e94aa6c6766df301716bc.png host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=1ms connect=2ms service=4ms status=200 bytes=3932
2013-02-03T20:34:19+00:00 heroku[router]: at=info method=GET path=/assets/star-02718a47b29575c2d7a0e75ac8bebf4d.png host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=2ms service=4ms status=200 bytes=3104
2013-02-03T20:34:19+00:00 heroku[router]: at=info method=GET path=/assets/empty_star-9bf002077eafec40cf239068f7d4d1ca.png host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=1ms service=43ms status=200 bytes=3072
2013-02-03T20:34:23+00:00 heroku[router]: at=info method=GET path=/emails/new host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=1ms service=119ms status=200 bytes=3022
2013-02-03T20:34:23+00:00 heroku[router]: at=info method=GET path=/assets/application-74fd2354261a1131b26861b47bef1d87.css host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=2ms service=4ms status=304 bytes=0
2013-02-03T20:34:19+00:00 heroku[router]: at=info method=GET path=/assets/headshot-767c8913c7af4fc97cb8e15881884f0e.png host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=4ms connect=6ms service=11ms status=200 bytes=146892
2013-02-03T20:34:39+00:00 heroku[router]: at=info method=POST path=/emails host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=0ms connect=7ms service=131ms status=500 bytes=643
2013-02-03T20:34:39+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=<appname>-2591.herokuapp.com fwd=69.181.104.85 dyno=web.1 queue=0 wait=1ms connect=3ms service=5ms status=200 bytes=0
由于它没有显示在您的SendGrid仪表板上,我猜您的凭据在应用程序中是错误的。如果键入
heroku config
,您是否看到SENDGRID\u用户名
和SENDGRID\u密码
设置正确
此外,您可能希望尝试将传递错误设置为显示在配置文件中
config.action_mailer.raise_delivery_errors = true
由于它没有显示在您的SendGrid仪表板上,我猜您的凭据在应用程序中是错误的。如果键入
heroku config
,您是否看到SENDGRID\u用户名
和SENDGRID\u密码
设置正确
此外,您可能希望尝试将传递错误设置为显示在配置文件中
config.action_mailer.raise_delivery_errors = true
只是想澄清一下,您无法访问SendGrid站点上的帐户设置,因为Heroku已将其锁定。您可以直接从Heroku界面调整这些设置。只是为了澄清一下,您无法访问SendGrid站点上的帐户设置,因为Heroku已将其锁定。您可以直接从Heroku界面调整这些设置。刚刚添加了最后一行。我100%确信用户名是准确的,并且Sendgrid密码在那里,我没有添加任何内容(而且,出于某种原因,Sendgrid的仪表板说我无法访问我的帐户详细信息),所以我假设这是正确的。我将使用该行再试一次,看看它是否会引发任何有趣的错误。谢谢对你的第一个建议完全正确。出于某种原因,该密码已关闭,尽管我无法(现在仍然无法)访问我的帐户设置,但我能够重置密码并将其更改为其他内容。当我这么做的时候,电子邮件就像魔术一样发出。(刚刚忘记检查,因此更新延迟)。谢谢酷。如果要访问SendGrid仪表板,可能需要通过主网站注册SendGrid帐户。很高兴你把事情解决了!刚刚添加了最后一行。我100%确信用户名是准确的,并且Sendgrid密码在那里,我没有添加任何内容(而且,出于某种原因,Sendgrid的仪表板说我无法访问我的帐户详细信息),所以我假设这是正确的。我将使用该行再试一次,看看它是否会引发任何有趣的错误。谢谢对你的第一个建议完全正确。出于某种原因,该密码已关闭,尽管我无法(现在仍然无法)访问我的帐户设置,但我能够重置密码并将其更改为其他内容。当我这么做的时候,电子邮件就像魔术一样发出。(刚刚忘记检查,因此更新延迟)。谢谢酷。如果要访问SendGrid仪表板,可能需要通过主网站注册SendGrid帐户。很高兴你把事情解决了!
config.action_mailer.raise_delivery_errors = true