我正在配置在用户使用设备注册后发送的电子邮件确认。我做了这句话所说的一切(https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users 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] /cdn-cgi/l/email-protection'
# 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
设置。请根据需要在代码中添加您的电子邮件和密码。
希望它能正常工作!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)