Heroku not sending email with Gmail SMTP

后端 未结 3 1398
既然无缘
既然无缘 2020-12-04 02:45

The app works everything, I\'m trying to use Confirmable with Devise, on my Rails app it says that the email was sent, but I never receive it. I\'m configuring it with Gmail

相关标签:
3条回答
  • 2020-12-04 03:19

    First heroku does not allow to send mails for free, you need to set up your credit card details to send mails, Secondly

    Check you have rightly configured

    open development.rb and update with the following

    config.action_mailer.delivery_method = :smtp
      config.action_mailer.default_url_options = { host:'localhost', port: '3000' }
      config.action_mailer.perform_deliveries = true
      config.action_mailer.raise_delivery_errors = true
      config.action_mailer.default :charset => "utf-8"
      config.action_mailer.smtp_settings = {
          :address => "smtp.gmail.com",
          :port => 25,
          :domain => 'localhost:3000',
          :user_name => "email id",
          :password => "password",
          :authentication => :plain,
          :enable_starttls_auto => true
      }
    
    0 讨论(0)
  • 2020-12-04 03:31

    I was running into a similar issue. The problem I was having was that I wasn't telling Heroku to copy my configuration variables over to Heroku as environment variables. I used the figaro gem and the smtp email worked after entering this command:

    figaro heroku:set -e production
    

    I would recommend that you make sure that you are using the correct gmail username and password.

    For more information checkout this tutorial. I can confirm that it works http://usingname.space/2015/07/25/gmail-smtp-ruby-on-rails-actionmailer-and-you/

    0 讨论(0)
  • 2020-12-04 03:33

    You have to check two important things when you want to send emails via Gmail smtp:

    1. Your apps configuration:

      • host: smtp.gmail.com
      • port: 587 or 465 (587 for tls, 465 for ssl)
      • protocol: tls or ssl
      • user: YOUR_USERNAME@gmail.com
      • password: YOUR_PASSWORD
    2. The given Gmail account settings:

      • If you've turned on 2-Step Verification for your account, you might need to enter an App password.
      • Without 2-Step Verification:
        1. Allow less secure apps access to your account.
        2. Visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in with your Gmail username and password.
    0 讨论(0)
提交回复
热议问题