【发布时间】:2016-12-29 09:28:46
【问题描述】:
我正在使用设备进行身份验证。它提供了一个忘记密码的链接。当我发送电子邮件时,电子邮件不会发送。以下是我使用的设置。你能告诉我为什么gmail不发送电子邮件吗?我还打开了“允许不太安全的应用程序发送电子邮件”,并且我还在 gmail 设置中启用了 imap。
application.rb 有以下设置。
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:domain => 'mail.google.com',
:port => 587,
:user_name => 'validemail@gmail.com',
:password => 'validpassword',
:authentication => 'login',
:enable_starttls_auto => true
}
development.rb 有
config.action_mailer.default_url_options = { host: '127.0.0.1'}
config.action_mailer.delivery_method = :smtp
发送电子邮件后,我在控制台中收到以下文本。
Devise::Mailer#reset_password_instructions: processed outbound mail in 215.2ms
Sent mail to validemail@gmail.com (1097.6ms)
Date: Thu, 29 Dec 2016 09:50:41 +0000
From: please-change-me-at-config-initializers-devise@example.com
Reply-To: please-change-me-at-config-initializers-devise@example.com
To: validemail@gmail.com
Message-ID: <5864dc7161acb_173921a07788707d@kofhearts-rubyonrails-3267120.mail>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello validemail@gmail.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://127.0.0.1/users/password/edit?reset_password_token=WQxYad91mPghMxaurYA5">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>
Redirected to https://rubyonrails-kofhearts.c9users.io/users/sign_in
Completed 302 Found in 1965ms (ActiveRecord: 14.7ms)
更新:
我只是在学习本教程。
https://www.youtube.com/watch?v=ZEk0Jp2dThc
发送电子邮件不适用于此视频中指定的设置。
【问题讨论】:
-
我知道这不是您问题的答案,但我放弃了通过 gmail 使用 smtp。我现在使用
sendinblue,他们有一个 smpt 服务,每天大约 300 封电子邮件是免费的。也是一个很好的红宝石,所以它很容易使用。
标签: ruby-on-rails devise