Almaron
Almaron

Reputation: 4147

ActionMailer ArgumentError - SMTP-AUTH requested but missing secret phrase

I am using Yandex Connect (SMTP) as a method to send emails from my Rails 5 JSON API app.

Here's the setup:

Rails.application.configure do
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.smtp_settings = {
    address:              'smtp.yandex.com',
    port:                 25,
    domain:               ENV['MAIL_DOMAIN'],
    user_name:            ENV['MAIL_USER'],
    password:             ENV['MAIL_PASSWORD'],
    authentication:       'plain',
    enable_starttls_auto: true
  }
end

I also have config.action_mailer.default_url_options = { host: ENV['MAIL_DOMAIN'] } set in my application.rb

On heroku with the right credentials it works just fine. But when I try to run the same config localy and send an email, I get ArgumentError - SMTP-AUTH requested but missing secret phrase.

What could be wrong

Upvotes: 1

Views: 3695

Answers (1)

Dennis Krupenik
Dennis Krupenik

Reputation: 676

1) Make sure the environment variables are really there, e.g. bundle exec rails console, puts ENV.inspect

2) Make sure the credentials are correct

3) Restart your development server after you've modified your environment. This includes spring stop.

Upvotes: 2

Related Questions