Can't get net/smtp to send outside of LAN?

I am trying to use net/smtp to send a mail message. What I am finding
is
that I can send a email message on the LAN but it never gets out to the
world. What am I missing?

Here is my test code:
####################################################################
require(‘net/smtp’)

class Email
def Email.send(date, body, server = ‘localhost’, port = 25)
Net::SMTP.start(server, port) { |mailer|
text =
“From: info\n” <<
“To: usr@domain\n” <<
“Date: #{date}\n” <<
“Subject: New entry in Database\n” <<
“Importance: High\n” <<
“MIME-Version: 1.0\n” <<
“Sender: #{self.class.name}\n” <<
“\n\n\n” <<
body

  mailer.send_message(text, "info", "usr@domain")
  }

end

end

Email.send("#{Time.now}", “New entry in database at #{ Time.now}\n”)
puts “end of code”
####################################################################
on the LAN SMTP server with ‘localhost’ and usr@domain being a user on
the
same machine WORKS OK … with ‘localhost’ replaced with ‘machine’ where
machine is the machine on the LAN that sends SMTP mail and usr@domain is
a
user on that same machine and the code is run anywhere on the LAN it
WORKS
OK to a user on ‘machine’ …

HOWEVER …

if usr@domain is outside the LAN the mail never gets sent either if the
code
is run on ‘localhost’ or on a machine on the LAN with ‘machine’ replaced
by
the IP of the SMTP server. I know ‘machine’ will serve as a SMTP host
for
mailers such as evolution or Mac OX X mailer because I use it for that
all
the time.

What am I missing.

I know I could go to a better Ruby package such as TMail or RubyMail or
bring out the cannons and use ActionMailer but if I don’t understand
what
is happening at this basic level that might not help either.

All comments welcome
john

John N. Alegre wrote:

I am trying to use net/smtp to send a mail message. What I am finding is
that I can send a email message on the LAN but it never gets out to the
world. What am I missing?

I think you are forgetting login credentials such as
…acct=“username”, passwd=“password”, authtype=:login as part of the
instance’s construction.

gregarican wrote:

I think you are forgetting login credentials such as
…acct=“username”, passwd=“password”, authtype=:login as part of the
instance’s construction.

but is this necessary???

When I set the SMTP server as host on mailers such as evolution or the
Mac
OX X mailer I use no user / pass authorization. I just pass the mail to
that machine using SMTP. Why would this be different from Ruby code?

John N. Alegre wrote:

When I set the SMTP server as host on mailers such as evolution or the Mac
OX X mailer I use no user / pass authorization. I just pass the mail to
that machine using SMTP. Why would this be different from Ruby code?

Are you 100% sure there is no username/password combo stored in a
keychain or any other place on your Mac? If there is that’s why the Mac
is automatically referencing this. Much like how my Outlook/Exchange
environment stores my information. But if I want to access raw SMTP
using Ruby I need to manually authenticate. Just a wild guess…

gregarican wrote:

Are you 100% sure there is no username/password combo stored in a
keychain or any other place on your Mac?

Yes there is nothing set in mailers from three different platforms. 2
other
linux boxes and one Mac (evolution or Mac Mailer) there is an “Trusted
Net:” entry in the firewall config but this would be the same for the
code
as for the mailers.

another follow up… the code I posted does not work from the same usr
same
machine where login would not be necessary.

On Mar 9, 2006, at 3:33 PM, gregarican wrote:

Are you 100% sure there is no username/password combo stored in a
keychain or any other place on your Mac? If there is that’s why the
Mac
is automatically referencing this. Much like how my Outlook/Exchange
environment stores my information. But if I want to access raw SMTP
using Ruby I need to manually authenticate. Just a wild guess…

Are you sure you’re not confusing SMTP with POP? You as a general
rule don’t have to authenticate with SMTP, although many SMTP
servers do have some form of authentication (e.g. require someone to
log in with POP first, etc.)

Logan C. wrote:

Are you sure you’re not confusing SMTP with POP? You as a general
rule don’t have to authenticate with SMTP, although many SMTP
servers do have some form of authentication (e.g.  require someone to
log in with POP first, etc.)

Yes this is definately the
case.  I obtained a Perl script that sends email
to the SMTP server I am trying to work with the Ruby code on and it
works
fine after I change what I got to the hostname of the SMTP
server.  Greg is
confusing POP with SMTP.

But back to the code.

Again I post my Ruby test code …require(‘net/smtp’)

########################################################
class Email
  def Email.send(date, body, server = ‘localhost’, port = 25)
    Net::SMTP.start(server, port) { |mailer|
      text =Â
      "From: info\n" <<Â
      "To: usr@domain\n"       <<
      "Date: #{date}\n"          <<
      "Subject: New entry in Database\n"        <<
      "Importance: High\n"           <<
      "MIME-Version: 1.0\n"          <<
      "Sender: #{self.class.name}\n" <<
      "\n\n\n"                       <<
      body

      mailer.send_message(text, “info”, “usr@domain”)
      }
  end

Email.send(“#{Time.now}”, “New entry in database at #{ Time.now}\n”)
puts “end of code”
########################################################
This works to send mail to a user on the SMTP server
machine.  This machine
has 30 users and I can send mail to any of those users, routed
correctly.
Any email address outside the LAN disappers.

Here is the entry in the mail log:

endMar 10 09:21:31 libros postfix/smtp[24290]: 0F60E13FB0: host
mailfoundry-2.iphouse.net[216.250.188.211] said: 450 Domain in
Reverse-Path
resolves to an invalid IP address (in reply to RCPT TO command)
Mar 10 09:21:33 libros postfix/smtp[24290]: 0F60E13FB0:
to=[email protected],
relay=mailfoundry-1.iphouse.net[216.250.188.210],
delay=4, status=deferred (host
mailfoundry-1.iphouse.net[216.250.188.210]
said: 450 Domain in Reverse-Path resolves to an invalid IP address (in
reply to RCPT TO command))

so the domain, even though it is correct is somehow being munged by Ruby
to
something that the downstream realy does NOT understand. (here
[email protected] is the valid email address I used in the code.

???
john

For anyone who has been following this thread I have solved the problem.
Well I guess a better term is there never was a problem. Two months ago
I
changed IPs and got a new block of static IPs. The entry for reverse
DNS
lookup on the mail software they use was set to require reverse DNS for
email. Things like evolution or the Macintosh OS X mailers do reverse
DNS
so those things worked fine. The raw code however did not handle revers
DNS so the mail send failed. Once they changed the entry the code shown
below will send mail out just fine.

Hope this helps someone else.

Peace
john