Running SMTP in JRuby 1.0I get this rather
unhelpful error message:

   An existing connection was forcibly
   closed by the remote host

In Ruby, I get this, which gives me some
clue as to the error I need to fix:

    Invalid argument

Of course, it still doesn't tell me which of
the several arguments is invalid, and I still
haven't got it to work, despite trying 24
combinations of arguments, but that's another
matter.

Thankfully, Ruby makes it try all the options.
If anyone has a clue as to what's going wrong,
it would be wonderful. (I've included the code
below, just in case.)

Code (for the morbidly curious)
-------------------------------
# mailer.rb
#

require 'net/smtp'

from_alias = 'My Name'
from_addr = '[EMAIL PROTECTED]'
to_id = "Test Recipient <[EMAIL PROTECTED]>"
to_addr = '[EMAIL PROTECTED]'
to_list   = ['[EMAIL PROTECTED]']

subject = "Test Message"
msg = <<END_OF_MSG
This is a test message
END_OF_MSG

# Message-send parameters
@smtp_addr = 'smtp.att.yahoo.com'
@port = 465
@passwd = 'myPassword'

# Email header shows:
#  [EMAIL PROTECTED]@69.107.83.118
#  email thinks the helo might be 69.107.83.118 (it isn't sure)
#
# Possible Values
#   User: [EMAIL PROTECTED], myName
#   Helo: 69.107.83.118, sbcglobal.net,
#         [EMAIL PROTECTED], nil
#   Auth: :login, :plain, :cram_md5

[:login, :cram_md5, :plain].each do |auth|
["[EMAIL PROTECTED]", "erictreelight"].each do |user|
["69.107.83.118", "sbcglobal.net", "[EMAIL PROTECTED]", nil].each do |helo|
  begin
    Net::SMTP.start(@smtp_addr, @port) do |smtp|
      smtp.enable_ssl
      smtp.helo(helo)
      smtp.authenticate(user, @passwd, auth)
      smtp.send_message(msg, from_addr, to_addr)
      puts ["Success:", user, helo, auth].join(" ")
      exit
    end
  rescue Net::SMTPAuthenticationError => error
    puts ["Failed: Authorization", user, helo, auth, error].join(" ")
  rescue Net::SMTPFatalError => error
    puts ["Failed: 5xx", user, helo, auth, error].join(" ")
  rescue Net::SMTPServerBusy => error
    puts ["Failed: TEMPORARY 420/450", user, helo, auth, error].join(" ")
  rescue Net::SMTPSyntaxError => error
    puts ["Failed: 500", user, helo, auth, error].join(" ")
  rescue Net::SMTPUnknownError => error
    puts ["Failed: Unexpected", user, helo, auth, error].join(" ")
  rescue IOError => error
    puts ["Failed: IOError", user, helo, auth, error].join(" ")
  rescue => error
    puts ["Failed: Timeout", user, helo, auth, error].join(" ")
  end
end
end
end
puts "Done: No successful combination found."
exit






---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to