Action Mailer Driving me insane

Ok, maybe its a short walk, not a drive…

I have it working just fine using smtp in development env from my OSX
machine. When I deploy it to the server (which happens to be the same
box where the smtp server lives), no email, no errors, nothing in the
Postfix logs.

I’ve double checked that my production and development action mailer
settings are identical. Here’s whats in the production.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => “mydomain.com”,
:port => correct port,
:domain => “mydomain.com”,
:authentication => :plain,
:user_name => “[email protected]”,
:password => “the password”
}

When the app fires off an email, the rails log shows:
Sent mail to [email protected]

but the postfix logs on the smtp server show absolutely nothing related
to this attempted email. When I send one from the development app
running on osx, I can easily find it in the postfix logs.

Help??? What could make actionmailer think everything is fine, and yet
the smtp server never even hears about it???

thanks,
jp

On Jul 6, 8:23 pm, Jeff P. [email protected]
wrote:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => “mydomain.com”,
:port => correct port,
:domain => “mydomain.com”,
:authentication => :plain,
:user_name => “[email protected]”,
:password => “the password”

random guess - do you need 127.0.0.1 or something like that rather
than mydomain.com ? Sometimes smtp etc is firewall on the external
interface.

Fred

Frederick C. wrote:

On Jul 6, 8:23�pm, Jeff P. [email protected]
wrote:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => “mydomain.com”,
:port => correct port,
:domain => “mydomain.com”,
:authentication => :plain,
:user_name => “[email protected]”,
:password => “the password”

random guess - do you need 127.0.0.1 or something like that rather
than mydomain.com ? Sometimes smtp etc is firewall on the external
interface.

Fred

Thanks Fred,
No joy. I even went so far as to put in “kungfoopanda.com” and verified
that on my local machine this gives me a delivery error, while on the
real server, no errors are generated. For some reason, action mailer is
not even trying to send it, but is claiming it has been sent.

;{
jp

Jeff P. wrote:

Thanks Fred,
No joy. I even went so far as to put in “kungfoopanda.com” and verified
that on my local machine this gives me a delivery error, while on the
real server, no errors are generated. For some reason, action mailer is
not even trying to send it, but is claiming it has been sent.

;{
jp

Another clue. I just went back to the development machine and forced
script/server to run in production mode (script/server -e production),
and it still works from the Mac in production mode. I believe this
removes the onus from the production config; I’m not sure where to point
the finger now though.

thanks,
jp

Craig W. wrote:

On Sun, 2008-07-06 at 22:39 +0200, Jeff P. wrote:

jp

Another clue. I just went back to the development machine and forced
script/server to run in production mode (script/server -e production),
and it still works from the Mac in production mode. I believe this
removes the onus from the production config; I’m not sure where to point
the finger now though.


can the ‘production’ server actually send out traffic on port 25 (i.e.
firewall or other routing issues?)

can you telnet from the production server to the smtp server on port 25?

Craig

It is not on port 25 for safety reasons.

The production server and the server with the smtp are the same box.

From the mac I can telnet to the smtp server on its proper port. From
the production server (which is also the smtp server), it gives me
connection refused. I guess this is the problem. Why didn’t it give a
delivery error???

Should I use :sendmail on the production server instead? What setup
will I need to do in my Postfix to make it allow that?

thanks,
jp

On Sun, 2008-07-06 at 22:39 +0200, Jeff P. wrote:

jp

Another clue. I just went back to the development machine and forced
script/server to run in production mode (script/server -e production),
and it still works from the Mac in production mode. I believe this
removes the onus from the production config; I’m not sure where to point
the finger now though.


can the ‘production’ server actually send out traffic on port 25 (i.e.
firewall or other routing issues?)

can you telnet from the production server to the smtp server on port 25?

Craig

On Sun, 2008-07-06 at 23:08 +0200, Jeff P. wrote:

can the ‘production’ server actually send out traffic on port 25 (i.e.
From the mac I can telnet to the smtp server on its proper port. From
the production server (which is also the smtp server), it gives me
connection refused. I guess this is the problem. Why didn’t it give a
delivery error???

Should I use :sendmail on the production server instead? What setup
will I need to do in my Postfix to make it allow that?


why on earth would you decide to run smtp on a port other than 25 and
call it ‘safety reasons?’ SMTP servers are fully hardened and have
sophisticated methods to decide who is allowed to relay and mail and who
isn’t.

I wouldn’t know because I haven’t tested it and I’ve never considered
moving smtp to another port than port 25 but it might work if you just
use 127.0.0.1:YOUR_SMTP_PORT_NUMBER but there’s not a chance in the
world anyone could have helped you with your problem connecting to an
odd port if you don’t tell us.

Craig

Well, on my machine… I run SMTP on port 24 AND 25. Port 25 is
filtered by my home ISP, while 24 slips right through…

Port 24 is, however, hardened in the manner you stated. And if the
SMTP server and application are on the same machine, there’s no reason
to change the port, just configure smtp to only listen on loopback
(127.0.0.1, and ::1, for those cool IPv6 people)

On Sun, 2008-07-06 at 21:13 -0500, Michael G. wrote:

Well, on my machine… I run SMTP on port 24 AND 25. Port 25 is
filtered by my home ISP, while 24 slips right through…

Port 24 is, however, hardened in the manner you stated. And if the
SMTP server and application are on the same machine, there’s no reason
to change the port, just configure smtp to only listen on loopback
(127.0.0.1, and ::1, for those cool IPv6 people)


if you spent the same amount of energy detailing your setup as you do
justifying your mail setup it would be easier to help. Is rails running
on your home LAN? Is your mail server on your home LAN?

Craig

Craig W. wrote:

On Sun, 2008-07-06 at 22:39 +0200, Jeff P. wrote:

jp

Another clue. I just went back to the development machine and forced
script/server to run in production mode (script/server -e production),
and it still works from the Mac in production mode. I believe this
removes the onus from the production config; I’m not sure where to point
the finger now though.


can the ‘production’ server actually send out traffic on port 25 (i.e.
firewall or other routing issues?)

can you telnet from the production server to the smtp server on port 25?

Craig

Ok, I’m at a point now where I can ssh into the server box (the box that
runs both the rails app and the smtp server) with an ordinary user
account (not root or anything special). From there I can telnet in on
port 25 and successfully send an email to a domain that is not related
to that box.

Even with that, I can find no combination of smtp settings that will
make ANY of the following happen:

  1. successful email
  2. delivery failure exception
  3. anything at all showing up in the postfix log

It is acting exactly as it would if the delivery type was set to :test,
but it clearly isn’t as seen above. The test database has not been
created yet or migrated, so I’m quite sure I’m not somehow running with
test environment. Can anybody suggest something else to look at
here???

FWIW, this is Rails 2.1, running on lighttpd proxied through apache (I
have many different things on this box, and that seems to be the
simplest way). The box is running RHEL4 OS. The mail server is
postfix. The postfix config is mostly unmollested, save the addition of
all of my domains to the “destinations” list.

thanks,
jp

On Mon, 2008-07-07 at 04:42 +0200, Jeff P. wrote:

can the ‘production’ server actually send out traffic on port 25 (i.e.
to that box.
test environment. Can anybody suggest something else to look at
here???

FWIW, this is Rails 2.1, running on lighttpd proxied through apache (I
have many different things on this box, and that seems to be the
simplest way). The box is running RHEL4 OS. The mail server is
postfix. The postfix config is mostly unmollested, save the addition of
all of my domains to the “destinations” list.


if you can telnet from the rails server to smtp server on port 25 (even
if it’s the same system), then all you need to do is to use the same
settings that you used in your telnet session in the actionmailer. The
same hostname, and if you don’t need to authenticate to send mail, don’t
use authentication settings (I’m gathering that you don’t have
authentication setup in postfix by your description above).

Thus if you used ‘telnet localhost 25’ for connecting, then you use
localhost as the ‘address’. i.e

ActionMailer::Base.smtp_settings = {
:address => “localhost”,
:port => 25,
:domain => “www.example.com
#:user_name => “[email protected]”,
#:password => “mypass”,
#:authentication => :login
}

Craig

Craig W. wrote:

On Mon, 2008-07-07 at 04:42 +0200, Jeff P. wrote:

can the ‘production’ server actually send out traffic on port 25 (i.e.
to that box.
test environment. Can anybody suggest something else to look at
here???
snip
Thus if you used ‘telnet localhost 25’ for connecting, then you use
localhost as the ‘address’. i.e

ActionMailer::Base.smtp_settings = {
:address => “localhost”,
:port => 25,
:domain => “www.example.com
#:user_name => “[email protected]”,
#:password => “mypass”,
#:authentication => :login
}

Craig

Thanks Craig,
It is working now using your suggested reduced config above. I still
don’t understand why I couldn’t find any grief in any of the various log
files. Also, why no delivery failure exceptions?!?!?!?!?!? That’s
just WRONG!

thanks for the help,
jp

Michael G. wrote:

Well, on my machine… I run SMTP on port 24 AND 25. Port 25 is
filtered by my home ISP, while 24 slips right through…

Port 24 is, however, hardened in the manner you stated. And if the
SMTP server and application are on the same machine, there’s no reason
to change the port, just configure smtp to only listen on loopback
(127.0.0.1, and ::1, for those cool IPv6 people)

Hi Michael,
The smtp server is also used for regular mail for my several other
domains, so I can’t config it for ONLY local.

I’m becoming more and more certain that the problem lies before the smtp
config though, based on the fact that I’ve never gotten anything to show
up in the postfix log despite a dozen different configs, and also it
never gives me a delivery failure exception despite having it set for
that.

My other reply just above provides some more details about my setup.

thanks,
jp