【发布时间】:2015-04-09 15:44:50
【问题描述】:
我正在为我的应用程序实施设计邮件,我已完成以下步骤:
在模型中:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
end
然后我添加了 confirmation_token、confirmed_at、 Confirmation_sent_at
在 devise.rb 中,我添加了:
config.mailer_sender = 'example@gmail.com'
#config.mailer = 'Devise::Mailer'
在 development.rb 中:
config.assets.raise_runtime_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "example@gmail.com",
:password => "somepassword",
:enable_starttls_auto => true
}
一切正常。但是没有生成电子邮件。 在我的控制台中,我正在获取邮件信息和链接..
我的控制台:
Sent mail to example@yahoo.com (2597.8ms)
Date: Wed, 08 Apr 2015 23:39:09 +0530
From: example@gmail.com
Reply-To: example@gmail.com
To: example@yahoo.com
Message-ID: <55256ec5ba47e_26f51d984dc117aa@itadmin-HP-Pavilion-17-Notebook-PC.mail>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello exmple@yahoo.com!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><a href="http://localhost:3000/users/password/edit?reset_password_token=M5os3tBYHQrsRaw4TtTt">Change my password</a></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
我没有添加任何设计密码控制器/注册控制器。 当我单击忘记密码并输入电子邮件并单击“向我发送重置密码说明”按钮时出现错误。 这是错误,我得到了:
Net::SMTPAuthenticationError in Devise::PasswordsController#create
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsrrD-
我使用了Running into SMTP error when trying to send email in RoR app,但没有帮助我。 我可能有什么问题?
【问题讨论】:
-
我在这里回答了类似的问题:stackoverflow.com/a/25209735/1047207
标签: ruby-on-rails devise