Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send confirmation e-mails using gmail smtp service for registration using devise under development mode locally?

I have an app , it uses devise to send confirmation mails for the newly registered users , I have smtp settings under the development.rb file as

  config.action_mailer.default_url_options = { :host => 'http://localhost:3000' }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  :enable_starttls_auto => true,
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => "gmail.com",
  :authentication => :login,
  :user_name => "[email protected]",
  :password => "mygmail password"
    }

This is throwing me with an error like ,

Net::SMTPAuthenticationError in Devise::RegistrationsController#create

535-5.7.1 Please log in with your web browser and then try again. Learn more at

Any Ideas how to resolve this ?

Resolved using these settings ..

 config.action_mailer.default_url_options = { :host => 'localhost:3000' }
 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            => "[email protected]",
  :password             => 'my_gmail password',
  :authentication       => "plain",
  :enable_starttls_auto => true
  }
like image 434
Mansoor Elahi Avatar asked Jan 28 '26 12:01

Mansoor Elahi


1 Answers

I was unuable to resolve this problem with any code. After a while i logged in to gmail account and this is, what it gave me after.

We've detected suspicious activity on your Google Account. Please create a new password to continue using your account.

Read some tips on creating a secure password. 

So solution to this problem is simply log into account you use for email sending and reconfirm your new password

like image 65
mArtinko5MB Avatar answered Jan 31 '26 04:01

mArtinko5MB