Rails设计在开发中不发送电子邮件确认 [英] Rails devise not sending an email confirmation in development

查看:82
本文介绍了Rails设计在开发中不发送电子邮件确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将电子邮件确认配置为在用户使用devise注册后发送出去。我做了所有所说的事情( https:// github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users ),但仍然无法正常工作。

I'm configuring email confirmation to be sent out after the user signs up using devise. I did everything what this says (https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users) but it still does not work.

以下是一些代码:

//development.rb
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

//devise.rb
  config.mailer_sender = 'myEmail@gmail.com'
  # 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

为了在开发环境中发送电子邮件确认信,我是否还需要进行其他配置?

Do I need to configure something more in order to send email confirmation letter in development environment??

推荐答案

是的,您必须配置smtp设置,以便通过以下方式发送电子邮件:

Yes, You have to configure smtp settings for emails to be sent from like :

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 设置。请在需要的地方在代码中添加您的电子邮件和密码。
希望它能正常工作!

Add above code to your development.rb in order to configure smtp settings. Do add your email and password in the code where required. Hopefully It will work fine!

这篇关于Rails设计在开发中不发送电子邮件确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆