简体   繁体   中英

Rails 6 ArgumentError (SMTP-AUTH requested but missing user name)

I built a basic rails app only for contact form using - gem 'mail_form'. It works perfectly in the development environment. However, I deploy the app in Heroku and only got an error in the production environment.

config/environments/production.rb

  config.action_mailer_default_url_options = { host: "https://myapp.herokuapp.com" }
  # Rails.application.routes.default_url_options[:host] = 'https://gmail.com'
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: 'gmail.com',
    authentication: 'plain',
    enable_starttls_auto: true,
    user_name: ENV['GMAIL_EMAIL'],
    password: ENV['GMAIL_PASSWORD']
  }

enter image description here

Any helps would be appreciated.

There is no issue in your configuration, but fact is on Heroku they have following information

Gmail have protections in place to avoid their service being used to deliver spam, however these are not published for security reasons. However we often see issues where customer applications attempt to use a Gmail account for email delivery which is subsequently blocked. So it mean there is some sort of block.

You are suggested to use email add-ons from email add-ons

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM