Forum: Ruby on Rails ActionMailer not delivering mail from one particular server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ab0332f155332010af42635a03bdda4a?d=identicon&s=25 Aleksey Gladysh (Guest)
on 2015-04-04 08:56
(Received via mailing list)
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.

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'
    )
  end
end

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?
This topic is locked and can not be replied to.