我正在配置电子邮件确认,以便在用户使用devise注册后将其发送出去。我做了所有这些所说的事情(https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users),但是它仍然无法正常工作。
以下是一些代码:
//development.rb
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
//devise.rb
config.mailer_sender = '[email protected]'
# Configure the class responsible to send e-mails.
config.mailer = "Mailer"
//Mailer.rb
class Mailer < Devise::Mailer
helper :application
include Devise::Controllers::UrlHelpers
default template_path: 'devise/mailer'
end
我是否需要进行其他配置才能在开发环境中发送电子邮件确认信?
是的,您必须为要通过以下方式发送的电子邮件配置smtp设置:
require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
ActionMailer::Base.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default :charset => "utf-8"
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "YOUR_EMAIL",
:password => 'PASSWORD',
:authentication => "plain",
:enable_starttls_auto => true
}
将以上代码添加到您development.rb
的命令中以配置smtp
设置。请在所需的代码中添加您的电子邮件和密码。希望它将正常工作!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句