Reputation: 69
I have a Ruby on Rails (v4.1.5) application running on RedHat’s OpenShift. I was in the process of switching from Mandrill to SendGrid. In development I was able to add the following to my development.rb config file:
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:authentication => "plain",
:domain => ENV["DOMAIN_NAME"],
:enable_starttls_auto => true,
:user_name => ENV["SENDGRID_USERNAME"],
:password => ENV["SENDGRID_PASSWORD"]
}
And I could continue to use ActionMailer the same way I did before. I tested it locally and received emails and the headers showed they came through sendgrid.
Then I added this same code to production.rb and deployed to OpenShift. I added the new SENDGRID username and password environment variables used in the code above and verified they were set correctly on OpenShift.
But when I tested it, the log file says it sent the email to the correct email address but it doesn’t show up on my SendGrid dashboard and I have not received the email.
Does anyone know of any other log files on OpenShift that might show more info? I only looked at app-root/runtime/repo/log/production.log.
I have tried removing the enable_starttls_auto field above but nothing changed.
How can I debug this problem? I don’t know if it’s on the OpenShift side or SendGrid.
Upvotes: 0
Views: 1271
Reputation: 5383
First, do a direct connection with Telnet:
telnet smtp-relay.sendinblue.com 587
Trying 94.143.17.4...
If you get this error:
telnet: Unable to connect to remote host: Connection timed out
then, the problem isn't in Rails.
In my case, the problem was in the port number. My server is running on DigitalOcean which blocks connections to 587 ports, unless you ask them to unblock it, and they will unblock based on the hostname too, which means that it can work with mandrill but not with others.
Remember "2525" is the new "587", and this is true even for SendinBlue.
Other things to check if you get a timeout on telnet:
Disabling IPv6:
add the following lines to your /etc/sysctl.conf
:
#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Changes requires reboot.
You can test if IPv6 is disabled or not with
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
Upvotes: 0
Reputation: 3526
This article should help. I am not a Ruby expert so I can't really help.
https://developers.openshift.com/external-services/sendgrid.html
I know we have a lot of users using openshift and sendgrid.
Here is a PHP code repo - I know I know not the right language but a good example
https://github.com/sendgrid/openshift-sendgrid-php
Upvotes: 0