I’m looking for guidance on how to set up Gmail as an SMTP server in my Rails application version 2.3.5 with Ruby 1.9.1. I’m having trouble with the email configuration, as it leads to an authentication error.
Here’s the configuration I’m currently using with ActionMailer:
smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: 'mydomain.com',
user_name: '[email protected]',
password: 'mypassword',
authentication: 'plain',
enable_starttls_auto: true
}
When I try to send out emails, I encounter this error:
Net::SMTPAuthenticationError: 530 5.7.0 Must issue a STARTTLS command first.
Could anyone help me with this? I’m unsure if there’s something I need to modify in my settings to fix the STARTTLS requirement.
Had the same problem with old Rails setups. Rails 2.3.5 doesn’t play nice with Gmail’s STARTTLS anymore. Switch to port 465 with SSL - change your port to 465, add ssl: true, and ditch the enable_starttls_auto line. This creates a direct SSL connection instead of trying to upgrade it. Also, if you’ve got 2FA on, don’t use your regular password. Port 465 with direct SSL works way better on older Rails than the STARTTLS mess.
hey, i’ve had trouble with this too. try changing the authentication to ‘login’ instead of ‘plain’. that often helps with the STARTTLS issue. and yeah, port 587 is the way to go, which it seems you already did right.
That STARTTLS error is usually an SSL/TLS config issue, not authentication. Since you’re on Rails 2.3.5, try adding tls: true to your smtp_settings hash - Gmail’s gotten pickier about TLS versions. Also check that your OpenSSL supports the protocols Gmail wants. Oh, and if you’ve got two-factor auth turned on, you’ll need an app-specific password instead of your regular one. I hit the same thing with older Rails - fixing the TLS settings sorted it out.