Toontje
Toontje

Reputation: 1485

SMTP-AUTH requested but missing user name

currently I'm doing Daniel Kehoe's Learn Ruby on Rails tutorial. One of the exercises is to send a contact form from the Contact page using Google's Gmail account.

However, when I sent the contact form, instead of getting an email in my mailbox, I'm getting this error:

"SMTP-AUTH requested but missing user name"

In my config/application.yml file, I set my Gmail username and password.

Does anyone have an idea what could be the problem?

thanks for your help,

Anthony

Upvotes: 7

Views: 7758

Answers (2)

Daniel Kehoe
Daniel Kehoe

Reputation: 10952

For Rails 4.0 (Rails 4.1 uses a secrets.yml file to set credentials):

Check the file config/environments/development.rb, you should have this:

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: ENV["DOMAIN_NAME"],
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["GMAIL_USERNAME"],
    password: ENV["GMAIL_PASSWORD"]
  }
  # ActionMailer Config
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  # Send email in development mode.
  config.action_mailer.perform_deliveries = true

Try replacing ENV["GMAIL_USERNAME"] with your Gmail username.

You can set ENV["GMAIL_USERNAME"] in your Unix shell. Or set it in the file config/application.yml. If the username contains any non-alpha characters, you may need to enclose it in quotes in the file config/application.yml.

Upvotes: 6

S.M.Mousavi
S.M.Mousavi

Reputation: 5226

Just double check parameters name to be correct. For me changing username into user_name solved the problem.
If you like to see errors, change value of config.action_mailer.raise_delivery_errors into true. I have Rails 4 and it has not required any change of settings to working properly.
Thanks @Toontje and @Daniel Kehoe

Upvotes: 6

Related Questions