I have an app with registration using Devise gem and I have followed the Rails guide on Action Mailer Configuration for Gmail but when I click on Send me password reset instructions I don't receive any emails. This is what I have:
config/environments/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default :charset => "utf-8"
config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "example.com",
authentication: "plain",
user_name: ENV["TODO_USERNAME"],
password: ENV["TODO_PASSWORD"],
enable_starttls_auto: true
}
I have updated
config/initializers/devise.rb
with:
config.mailer_sender = 'myemail@gmail.com'
I have also tried chaning authentication: "plain"
to authentication: :plain
, I have tried this tutorial, this, this and this, they all provide the same configuration but it doesn't work. I have allowed less secure apps here but no luck. I have also tried removing
domain: "example.com"
completely and changing
config.action_mailer.default_url_options = { host: 'localhost:3000' }
to
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
but that didn't help either. I've also tried:
ActionMailer::Base.smpt_settings = {
...
}
instead but no luck.
I'v also tried putting this config to config/application.rb
, restarting the server severl times but no luck.
This is the console log when send =ing password reset instructions:
Devise::Mailer#reset_password_instructions: processed outbound mail in 15.9ms
Sent mail to [hidden email] (269.2ms)
Date: Thu, 31 May 2018 22:40:03 +0200
From: [hidden email]
Reply-To: [hidden email]
To: [hidden email]
Message-ID: <5b105da3af6e6_164325fb584383ef@Home.mail>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello [hidden email]!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><a href="http://localhost:3000/users/password/edit?reset_password_token=qeoAhLA2pevyy7wpbVEs">Change my password</a></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 460ms (ActiveRecord: 9.9ms)
I have already tried everything. Any ideas?
I am using Rails 5.2