Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails: How to Configure the Devise Mailer?

I have made an application on Ruby on Rails. I'm using Devise and I need to use the recoverable password feature. I found these configurations on development.rb:

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 = false
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 2525,
    domain: "gmail.com",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: "MY_EMAIL",
    password: "MY_PASS"
  }

When I test it, it looks okay, It doesn't throw any exception on the application, but the email never comes. Please, how can I configure this?

like image 460
Jorge do Carmo Avatar asked Feb 05 '23 01:02

Jorge do Carmo


1 Answers

For using locally, I recommend using something like letter_opener.

For deploying the app I'd recommend using a service like Sendgrid, it has a free tier that is good enough for small apps.

If you insist on using GMail for e-mails, try using TLS:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  domain: "gmail.com",
  port: 587,
  user_name: "[email protected]",
  password: "your_password",
  authentication: 'plain',
  enable_starttls_auto: true
}
like image 132
Pedro Nascimento Avatar answered Feb 16 '23 19:02

Pedro Nascimento