Ruby on Rails application throws SMTP Authentication Error

ruby-on-railssmtpsmtp-auth

I'm developing a Rails app which when I run it locally, it's able to send emails through a gmail account via smtp.

When I moved it to my server, it comes up with the following error for example when I try to create a new user.

Net::SMTPAuthenticationError in UsersController#create

535-5.7.1 Username and Password not accepted.

Best Answer

To make sure, your SMTP information should look like this:

# Correct configuration to get this working is:
config.action_mailer.smtp_settings = {
    :enable_starttls_auto => true,
    :address        => 'smtp.gmail.com',
    :port           => 587,
    :domain         => 'whatever.yourrubyapp.com',
    :authentication => :plain,
    :user_name      => 'username@gmail.com',
    :password       => 'password'
}