【发布时间】:2012-04-07 03:40:22
【问题描述】:
我为我的 heroku 应用设置了发送网格启动器。
我把它放在我的 config/environment.rb 中:
ActionMailer::Base.smtp_settings = {
:user_name => ENV["SENDGRID_USERNAME"],
:password => ENV["SENDGRID_PASSWORD"],
:domain => "my-sites-domain.com",
:address => "smtp.sendgrid.net",
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
我创建了这个类models/notifier.rb:
class Notifier < ActionMailer::Base
def notify()
mail(
:to => "my-email@gmail.com",
:subject => "New Website Contact",
:body => "body",
:message => "message",
:from => "website@my-sites-domain.com"
)
end
end
我把它放在另一个控制器中发送电子邮件:
def contact
Notifier.notify().deliver
redirect_to("/", :notice => "We Have Received Your Request And Will Contact You Soon.")
end
当我部署并尝试发送电子邮件时,我收到此错误:
Net::SMTPAuthenticationError(535 身份验证失败:用户名/密码错误
我已完全设置发送网格,它表示我已准备好发送电子邮件。
我还运行heroku config --long 来获取实际的密码和用户名并对其进行硬编码,但仍然给了我同样的错误。
【问题讨论】:
-
您的帐户是否已配置?
标签: ruby-on-rails ruby-on-rails-3.2