Ruby on Rails
Friday, April 3, 2015
We have a client who insisted on having their Rails app set up with Oracle DB on a Red Hat Enterprise Linux server behind their VPN. This is not a setup we are very familiar with as we generally run DigitalOcean droplets with Ubuntu and use MySQL/PostgreSQL. Needless to say, this has caused a lot of problems, including the latest mystery that we've yet to solve. We have this app running on an Ubuntu staging server where everything works fine, but the copy running on the RHEL server will not deliver emails through ActionMailer.
There are no errors or anything. The app behaves exactly as though the email has been delivered, however, there are no emails received. We've wasted several days trying different things and we still can't figure it out.
-- We use Postmark as our delivery service, and so far we have ruled out: Postmark, the VPN, firewalls, the Postmark gem, and the Mail gem. I've written several test scripts to test each layer, and the failure is at the ActionMailer level. Here are the tests:
require 'postmark'
client = Postmark::ApiClient.new(ENV['API_TOKEN'])
client.deliver( from: 'Foo Bar <foo@bar.com>', to: 'Foo Bar <foo@bar.com>', subject: 'Testing Postmark', text_body: 'We want to know if Postmark works on the server')
# => Success. We received the email
api_token = FooBar::Application.config.action_mailer.postmark_settings[:api_key]
message = Mail.new do from "Foo Bar <foo@bar.com>" to "Foo Bar <foo@bar.com>" subject "Testing Mail+Postmark" body "Testing the Mail gem."end
message.delivery_method Mail::Postmark, {:api_key => api_token}message.deliver
# => Success. We received the email
class TestActionMailer < ActionMailer::Base default from: 'foo@bar.com'
def test_mail mail( to: 'foo@bar.com', subject: 'Test ActionMailer', body: 'Testing ActionMailer' ) endend
TestActionMailer.test_mail.deliver
# => On Ubuntu: Success. On RHEL: Silent Failure
There are no errors or anything. The app behaves exactly as though the email has been delivered, however, there are no emails received. We've wasted several days trying different things and we still can't figure it out.
Another possibly relevant detail is that when we initially set the server up, SELinux was giving Apache+Passenger trouble, so we set SELinux to permissive mode and then it worked. I don't know what else to try. Why would the Mail gem work but ActionMailer silently fail on only one particular machine?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f8ac5741-ffe5-4e3c-accc-3c3024841c56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment