I’ve configured ActionMailer for SMTP delivery of emails, and have
configured “config/environment.rb” accordingly, including the address of
our (external, but fully operational - checked and double-checked
Sending out emails from my Windows development laptop works without a
hitch, but on a Linux staging server using the exact same source code
with the exact same config files it doesn’t work; the symptoms are as
If I put the name of the SMTP server in “config/environment.rb” I get
the following SocketError on the Linux box:
getaddrinfo: Temporary failure in name resolution /usr/lib/ruby/1.8/net/protocol.rb:206:in `initialize' ...
If I put the SMTP’s IP address in “config/environment.rb” instead of
it’s name, it doesn’t work either, but this time with a Errno::EACCES
instead of the SocketError (again on the Linux box):
Permission denied - socket(2) /usr/lib/ruby/1.8/net/protocol.rb:206:in `initialize' ...
Which is very strange, because if I run the following snippets on the
same Linux box, I don’t get any errors whatsoever:
ruby -rsocket -e 'p Socket.getaddrinfo("NAME_OF_SMTP", "smtp")' ruby -rsocket -e 'p Socket.getaddrinfo("IP_OF_SMTP", "smtp")'
So it doesn’t appear to be a firewall, proxy or other configuration
issue on the box that’s causing the problem.
Also, a small Ruby program that invokes “TCPsocket.new” on port 25 of
the SMTP server works correctly on the Linux box, and another small Ruby
program that invokes “Net::SMTP.start” directly (ie. outside of Rails)
to deliver an email via the same SMTP server correctly delivers the
email from that Linux box… it’s just Rails that seems to be unable to
deliver the email via SMTP.
So it doesn’t appear to be a Rails configuration issue (as the config
works on my Windows laptop) but at the same time it also doesn’t appear
to be a configuration issue of the Linux box (as Ruby outside of Rails
can correctly deliver email via SMTP) ???
I’ve gone through the stacktrace (attached below) with a fine comb, and
“TCPsocket.new” and “Net::SMTP.start” seem to be the most relevant
things to check (which I’ve successfully done, as mentioned above).
An earlier post on this mailing list seems to describe the same (or - at
least - sufficiently similar) issue:
but it appears no-one ever posted a follow-up.
Many, many thanks in advance for any help (fix, further pointers) you
PS - full Rails stacktrace (Rails 1.1.6, ActionMailer 1.2.5)