0

I setup the RoR4-Mailer a long time ago. It works fine. After a while I didn't get emails anymore. I can't remember how I setup it up, so I asked google. After resetup I get an Error as you can see at the bottom.

Can anybody tell me how I configurate it correctly ? (I only want to use the basics. No Devise or any other Gem.)

My Code-Snippets:

/config/initializers/setup_mail.rb:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
    address: "smtp.gmail.com",
    port: "587",
    domain: "gmail.com",
    user_name: ENV["MAIL_USERNAME"],
    password: ENV["MAIL_PASSWORD"],
    authentication: "plain",
    enable_starttls_auto: true,
}

/config/environments/development.rb:

# Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = true
  #default host-url
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => ENV["GMAIL_DOMAIN"],
      :authentication => "plain",
      :enable_starttls_auto => true,
      :user_name => ENV["GMAIL_USERNAME"],
      :password => ENV["GMAIL_PASSWORD"]
  }

/local_env.yml:

GMAIL_DOMAIN: 'gmail.com'
GMAIL_USERNAME: 'username@gmail.com'
GMAIL_PASSWORD: 'password'

/config/application.rb:

config.before_configuration do
  env_file = File.join(Rails.root, 'config', 'local_env.yml')
  YAML.load(File.open(env_file)).each do |key, value|
    ENV[key.to_s] = value
  end if File.exists?(env_file)
end

error-exception:

Net::SMTPAuthenticationError in AuthController#send_pwd_reset_instructions
530-5.5.1 Authentication Required.
Ismoh
  • 1,074
  • 2
  • 12
  • 35
  • 1
    setup mailer as http://stackoverflow.com/questions/23300150/actionmailer-not-working-when-i-change-gmail-password/23300459#23300459 – Shamsul Haque Jul 23 '14 at 14:41
  • Try logging in and determining if the account has been flagged for suspicious activity http://stackoverflow.com/questions/17227532/gmail-530-5-5-1-authentication-required-learn-more-at – dav1dhunt Jul 23 '14 at 15:32
  • @ShamsulHaque: If I don't use the ENV.Var it works fine. Thanks. But I will ask google how to use the ENV.Var correctly. – Ismoh Jul 24 '14 at 15:55

1 Answers1

0

Take a look at ShamsulHaque's comment:
"setup mailer as stackoverflow.com/questions/23300150/… – Shamsul Haque yesterday"

Ismoh
  • 1,074
  • 2
  • 12
  • 35
  • you should vote up if http://stackoverflow.com/questions/23300150/actionmailer-not-working-when-i-change-gmail-password/23300459#23300459 helped you. – Shamsul Haque Jul 25 '14 at 13:59