Reputation: 458
I'm relatively new to programming and very new to web development and have been working my way through a Ruby on Rails bootcamp over the past few weeks. The current step I'm on involves adding user authentication to my site using Devise, but I'm getting a "silent error" where the authentication email won't send.
In line with the guide I'm following as part of the bootcamp, I've gone through the following steps:
Configured it by appending the following to my development.rb file:
...
config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
end
Created a user model using devise before updating the [timestamp]_devise_create_users.rb file to include the confirmable option.
Ran rake db:migrate
Added the Sendgrid addon (confirmed using "heroku addon")
Created a setup_mail.rb initializer with the following code:
if Rails.env.development?
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.sendgrid.net',
port: '587',
authentication: :plain,
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
domain: 'heroku.com',
enable_starttls_auto: true
}
end
Installed the Figaro gem
production: SECRET_KEY_BASE
to a randomly generated token within secrets.ymlWithin Dev mode, the app now successfully loads the user sign-up form, but after signing up an authentication email is not sent. The following error is instead generated:
Net::OpenTimeout in Devise::RegistrationsController#create
I've looked around and it seems a few other people have reported the same error when using Cloud 9 but none have offered suggestions on how to resolve the problem. My (somewhat uneducated) theory is that the host setting in development.rb needs to be different or the port in setup_mail.rb needs to be different as I'm using the C9 service instead of a local machine - but I'm not sure how to find out what these should be set to (if indeed that is the problem).
So far I've tried
My User.rb file currently looks like this
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
end
Can anyone give me a clue as to what's going on?
Upvotes: 3
Views: 2607
Reputation: 5343
Change your port to something like 2525
, I was getting the same error it seems that cloud9
blocks the port 587
.
sample settings for mandrill and cloud9
(should work the same for send-grid
aswell)
config.action_mailer.default_url_options = { host: '0.0.0.0:8080' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.mandrillapp.com',
port: 2525,
enable_starttls_auto: true,
user_name: '<your-username>',
password: '<your-password>',
authentication: 'login'
}
Also any changes you make,you must restart the server each time.
Upvotes: 8