我正在尝试使Devise忘记密码的电子邮件在开发中运行,并且它非常复杂。我正在使用Rails 5.2.0,Ruby 2.4.2和Devise 4.4.3。
我一直收到SMTP未配置的发送域错误,除了Sparkpost用户(我确实为某些生产电子邮件设置了Sparkpost,但没有为此设置),我找不到在线任何地方引用的错误。该错误消息对于调试不是很有用。关于如何深入了解此问题的任何建议?
日志
11:40:24 web.1 | Rendered devise/mailer/reset_password_instructions.html.erb (4.0ms)
11:40:24 web.1 | Devise::Mailer#reset_password_instructions: processed outbound mail in 227.7ms
11:40:25 web.1 | Sent mail to user@test.com (815.6ms)
11:40:25 web.1 | Date: Sat, 04 Aug 2018 11:40:24 -0700
11:40:25 web.1 | From: xyz@careersprite.com
11:40:25 web.1 | Reply-To: xyz@careersprite.com
11:40:25 web.1 | To: user@test.com
11:40:25 web.1 | Message-ID: <5b65f3186dfb4_56ef3fcd581f21c8384d5@ggentschev-05276.local.mail>
11:40:25 web.1 | Subject: Reset password instructions
11:40:25 web.1 | Mime-Version: 1.0
11:40:25 web.1 | Content-Type: text/html;
11:40:25 web.1 | charset=UTF-8
11:40:25 web.1 | Content-Transfer-Encoding: 7bit
11:40:25 web.1 |
11:40:25 web.1 | Mail body...
11:40:25 web.1 |
11:40:25 web.1 | Completed 500 Internal Server Error in 1308ms (ActiveRecord: 7.9ms)
11:40:25 web.1 | Net::SMTPFatalError (550 5.7.1 Unconfigured Sending Domain <careersprite.com>
Devise初始化器
config.mailer_sender = 'xyz@careersprite.com'
Development.rb
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { :host => 'localhost', port: 3000}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
.env
GMAIL_DOMAIN=careersprite.com
GMAIL_USERNAME=xyz@careersprite.com
GMAIL_PASSWORD='Gmail app password redacted'
此处描述了应用密码:https://support.google.com/accounts/answer/185833?hl=en
Application_mailer.rb(不确定Devise邮件程序是否对此加以利用)
class ApplicationMailer < ActionMailer::Base
default from: "xyz@careersprite.com"
layout 'mailer'
end
Devise reset_password_instructions.html.erb是标准的。