How to set up password reset emails from gmail with clearance?

190 views Asked by At

I'm trying to create a clearance password reset email to send from a gmail account I created. What do I have to do to accomplish this and send the password reset email when someone clicks "reset password"? I already set

config.mailer_sender = '[email protected]'

Sorry if it is a dumb question, I am still new to rails and clearance.

1

There are 1 answers

2
Veridian Dynamics On

This is how you configure a specific email address to send from in Clearance. Place this in: config/initializers/clearance.rb

Clearance.configure do |config|
    config.mailer_sender = "[email protected]"
end

From the docs

But in Rails, you also need to configure the server to send your email. /config/environments/development.rb

# Gmail configuration
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'example.com',
  user_name:            ENV['EMAIL_USER'],
  password:             ENV['EMAIL_PASS'],
  authentication:       'plain',
  enable_starttls_auto: true
}

However, take close note of two things:

  1. This example uses the ENV variables EMAIL_USER and EMAIL_PASS which are custom environment variables that would need to exist in your bash session (eg. $ export [email protected])
  2. This example supposes you're only doing this in development (which should be true for sending from a personal Gmail account). If you want this in production, you should add the configuration in /config/environments/production.rb