Search code examples
ruby-on-railsemaildevise

Rails devise not sending an email confirmation in development


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.

Here are some codes:

//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??


Solution

  • 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
           }
    

    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!