Rails droplet, rails 4, gmail not sending

I have the following setup: Ubuntu Ruby on Rails on 14.04 (Nginx + Unicorn) (London location)

I have manually upgraded it to Rails 4. The application is running fine, but I cannot send e-mails.

I have followed the tutorials on adding the Gmail MX records, the domain is pointed to the droplet, so everything is fine.

The account to send from is on Gmail.

Rails settings are the following:

config.action_mailer.smtp_settings = { address: “”, port: 587, domain: “”, authentication: :login, enable_starttls_auto: true, user_name: Rails.application.secrets.email_provider_username, password: Rails.application.secrets.email_provider_password } config.action_mailer.default_url_options = { :host => “” } config.action_mailer.delivery_method = :smtp config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = false

By testing it on a local machine, the code itself can send e-mails using the same credentials both in development and in production mode, so not likely that it is the code.

I have also configured postfix on the server (although I am not sure if that was necessary), and could send a test e-mail from the command line.

Mails are still not working from Rails.

Any ideas where to look for the problem ???


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Just for reference for people with trouble getting email sending working that might reach this page in the future:

For some time now Digital Ocean droplets have SMTP traffic blocked by default (because of anti-spam regulations). If you need SMTP enabled on your droplet you have to issue a support ticket asking for it to be enabled.

default url is you domain

config.actionmailer.defaulturloptions = { :host => “” }

I actually figured this out.

I set this in production, to actually see the error: config.actionmailer.raisedelivery_errors = true

and it turned out that sending the email timed out, which after some research led me here: