Setting Up Devise & Sendgrid on Heroku

前端 未结 2 1923
一生所求
一生所求 2021-01-30 09:31

My site is hosted on Heroku and I installed the Sendgrid Add-On as it looked almost too good to be true - but so far none of the email functionality is working. I have read the

2条回答
  •  Happy的楠姐
    2021-01-30 09:52

    I just set up Devise and SendGrid this morning and have no problems. I'm going to resume the steps I took.

    First, install Devise and SendGrid. Congratulations, you've already done that ;)

    Then, for production, add this to your files:

    config/initializers/devise.rb :

    config.mailer_sender = "mail-to-send@from.com"
    

    Set up Rails ActionMailer to use SendGrid

    config/environments/production.rb
    config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
    ActionMailer::Base.smtp_settings = {
      :user_name            => ENV['SENDGRID_USERNAME'],
      :password             => ENV['SENDGRID_PASSWORD'],
      :address              => "smtp.sendgrid.net",
      :port                 => 587,
      :enable_starttls_auto => true,
      :authentication       => :plain,
      :domain               => "yourdomain.com"
    }
    

    And everything's working great with that. Sign up confirmations, password recovery...

    Also, you should use Logging Expanded (it's Free!) and check your logs with heroku logs --tail (for real time). If you still get errors, post your logs.

    Have a good day !

提交回复
热议问题