[Wtr-general] Using Ruby for email notification?
Adam Reed
areed at relocationcentral.com
Thu Mar 1 15:04:18 EST 2007
I have quite a few regression tests built in Ruby/Watir now, and I'd
like to schedule them to run overnight. I have also built a logging
function which is great, but I'd like to try to have the automated tests
e-mail me as well as write to the text logs. That leads me to ask you
guys -- has anyone used Ruby for e-mail?
Our company has an exchange server with smtp enabled so I can easily
connect to it via telnet, but I'm not sure how to achieve this in Ruby.
I've read the about.com article
(http://ruby.about.com/od/tutorials/ss/ruby_email.htm), but there is not
a whole lot of explanation for a few of the parameters, nor a lot of
online discussion about it (or at least Google can't find it).
The code they list is:
------------------------------------------------------------------------
-
require net/smtp
myMessage = <<END_OF_MESSAGE
From: Mickey Mouse <bigcheese at disney.com>
To: Donald Duck <quackjob at disney.com>
Subject: Contract Negotiations
Don't let the big guy bully you.
END_OF_MESSAGE
Net::SMTP.start('localhost', 25, 'localhost.localdomain', 'mickey',
'cheese', :login) do |smtp|
smtp.send_message myMessage, 'bigcheese.disney.com'
end
------------------------------------------------------------------------
-
When I try this with my company server information (which has been
verified), I get the following error:
c:/ruby/lib/ruby/1.8/net/smtp.rb:536:in `send0': mail destination not
given (ArgumentError)
from c:/ruby/lib/ruby/1.8/net/smtp.rb:472:in `send_message'
from emailtest.rb:12
from c:/ruby/lib/ruby/1.8/net/smtp.rb:379:in `start'
from c:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start'
from emailtest.rb:11
Thanks,
Adam
More information about the Wtr-general
mailing list