hellomello
hellomello

Reputation: 8587

Ruby on Rails: Sendgrid not retrieving in the email mailbox, works in terminal

In my terminal, it shows that its work, but I'm not getting the actual email from my gmail mailbox. I followed this https://youtu.be/YnGuALpJN1M, but can't figure out what the issue is. It also doesn't show in the sendgrid website any activity.

I'm trying to test sendgrid in development:

development.rb

Rails.application.configure do
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true

  # more codes

end

config/sedngrid_secrets.yml

development:
  SENDGRID_USERNAME: [email protected]
  SENDGRID_PASSWORD: something

config/environment.rb

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
}

What am I doing wrong here?

Upvotes: 0

Views: 110

Answers (1)

dtakeshta
dtakeshta

Reputation: 214

Try this in your development.rb file. Then remove the action mailer set up from your config/environment.rb

  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.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

  }

Upvotes: 1

Related Questions