I see you have tried identical settings on both servers but are having problems only on your production / non-local host environment.
This points to an issue with the network configuration of the environment itself.
In the command line on your same server as your application, try the following command
telnet smtp.gmail.com 587
You should see something like the following
telnet smtp.gmail.com 587
Trying 173.194.79.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP dd5sm276863pbc.85 - gsmtp
If you do not see this, you will most likely get a connection error. This means your machine does not have access to the gmail server. Likely problems are a) general outbound network connectivity, b) firewalls specifically blocking all outbound connections c) firewalls blocking/allowing connections to particular ports or hosts
If this does not work, also try the following ports in place of 587
telnet smtp.gmail.com 465
telnet smtp.gmail.com 25
If one of these is more successful, change your mail server settings to use accordingly.
Edit: We had quite a bit of trouble using Gmail and then Gmail with our custom domain. One thing that can help is to remove the :domain line from your configuration file, try without it.
For reference, here is my Gmail config in prod using our custom domain hosted by Gmail:
config.action_mailer.default_url_options = { :host => "my.website.com" }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'website.com',
user_name: 'user@website.com',
password: 'password',
authentication: 'plain',
enable_starttls_auto: true
}
Also, if you do have 2-factor authentication enabled on your Gmail account, you might want to disable it and try this again just to confirm it is not complicating the issue.