1

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.
masegaloeh
  • 17,978
  • 9
  • 56
  • 104
Spoons
  • 11
  • 1
  • 2
  • 1
    This seems to be more of a rails error message. Which environment are you running on you laptop, and which environment are you running on the server? – becomingwisest Apr 09 '12 at 23:23
  • Both are running rails 3.1.3 and ruby 1.8.7 - Laptop is running Ubuntu 11.10 and the Server is running the same but the server edition. – Spoons Apr 09 '12 at 23:27
  • Good details to know, but I meant more of that as defined by rails http://oldwiki.rubyonrails.org/rails/pages/Environments . Which file did you configure the mail server, port, username and password? – becomingwisest Apr 09 '12 at 23:30
  • If your server is not running in the development environment, or if the server has some sort of firewall blocking outbound connections. It could result in these errors. I'm guessing its the environment. – becomingwisest Apr 09 '12 at 23:38
  • Both are running the development environment. Would this then likely mean that the configuration for nginx is blocking the messages being sent or do you think it's the server? – Spoons Apr 09 '12 at 23:57
  • 1
    Are you in control of the server? If not you might want to talk to the sysadmin. If you are, you can try connecting to a remote SMTP server using Telnet to spoof a simple email (plenty of quick tutorials on that) to see if the connection works or where it's being blocked. – Bart Silverstrim Apr 10 '12 at 00:07

1 Answers1

1

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'
}
Wesley
  • 32,320
  • 9
  • 80
  • 116
  • This is nearly identical to what is in my development.rb file, it succeeds in sending emails from my laptop but not from my server. – Spoons Apr 10 '12 at 00:00