我正在为我的应用程序实现设计邮件程序,我已完成以下步骤:
模特中的:
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'
在development.rb中:
config.assets.raise_runtime_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:tls => 'true',
:domain => 'gmail.com',
:authentication => :plain,
:user_name => 'example@gmail.com',
:password => '326272814example'
}
当我点击忘记密码时,我收到的错误为:
Devise中的OpenSSL :: SSL :: SSLError :: PasswordsController #create
SSL_connect返回= 1 errno = 0状态= SSLv2 / v3读取服务器问候A:未知协议
通过一些链接,我补充道:
:enable_starttls_auto => false,
:openssl_verify_mode => 'none'
对于development.rb,但是没有帮助我。请帮帮我
答案 0 :(得分:0)
我认为你的某些smtp_settings对于gmail是不正确的。尝试
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: '<username>',
password: '<password>',
authentication: 'plain',
enable_starttls_auto: true }
(来自http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration-for-gmail)