我正在使用設計進行身份驗證。它提供了一個忘記的密碼鏈接。當我發送電子郵件時,電子郵件不會被髮送。以下是我使用的設置。你能告訴我爲什麼gmail不發送郵件嗎?我還打開了「允許安全性較低的應用程序發送電子郵件」,並且我還啓用了gmail設置中的imap。爲什麼設計不通過gmail smtp發送電子郵件?
application.rb具有以下設置。
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:domain => 'mail.google.com',
:port => 587,
:user_name => '[email protected]',
: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 [email protected] (1097.6ms)
Date: Thu, 29 Dec 2016 09:50:41 +0000
From: [email protected]
Reply-To: [email protected]
To: [email protected]
Message-ID: <[email protected]l>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello [email protected]!</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)
UPDATE:
我只是按照本教程。
https://www.youtube.com/watch?v=ZEk0Jp2dThc
發送電子郵件沒有與在此視頻中指定的設置工作。
可能是重複http://stackoverflow.com/questions/25735206/rails-4-smsmpauthenticationerror-535-5-7-0-authentication-failed/25884665#25884665 –
我知道這不是你的答案問題,但我放棄了通過Gmail使用smtp。我現在使用'sendinblue',他們有一個smpt服務,每天約300封電子郵件免費。也是一個很好的紅寶石,所以它很容易使用。 – Iceman