【发布时间】:2015-05-13 22:20:55
【问题描述】:
我刚刚在 Bloc 完成了我的 ruby 基础课程,我开始埋头研究 Rails 开发。事情进展顺利,直到我用设计和确认电子邮件遇到了这个障碍。我尝试使用谷歌搜索并查看其他一些问题,但实际上找不到任何可以让我从中汲取并适用于我的情况的任何问题。
我在注册帐户时收到以下错误。
Net::SMTPAuthenticationError in Devise::RegistrationsController#create
535 身份验证失败:用户名/密码错误
从第 #976 行附近的源代码中提取的错误
def check_auth_response(res)
unless res.success?
raise SMTPAuthenticationError, res.message
end
end
从其他帖子中,我知道您可能希望看到我有一个如下所示的 config/initializers/setup_mail.rb 文件:
if Rails.env.development?
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.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
}
end
这是一个 application.yml 文件示例:
SENDGRID_PASSWORD:
SENDGRID_USERNAME:
SECRET_KEY_BASE:
在有人建议之前,我的 config/environments/development.rb 中有以下内容:
config.action_mailer.default_url_options = { host: 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
# Override Action Mailer's 'silent errors' in development
config.action_mailer.raise_delivery_errors = true
如果您想查看任何其他文件,请告诉我,我会将它们添加到此帖子中。
【问题讨论】:
标签: ruby-on-rails ruby devise sendgrid