Seems pretty typical, all I have to do is ask for help and then all of a
sudden something I've been digging for for a month falls into my lap.
For anyone wondering:

from_addr = "[EMAIL PROTECTED]"
to_addr = "[EMAIL PROTECTED]"

email_text = <<"END_EMAIL"
To: "Me" <#{to_addr}>
From: #{from_addr}
Subject: That thar logfile turned up somethin'

Hi, #{to_addr},

Here's the email about the logfile thing.
END_EMAIL

# now the sendmail part...

IO.popen("/usr/sbin/sendmail #{to_addr}", "w") do |sendmail|
  sendmail.print email_text
end

# That's it...  Or, using SMTP directly:

require 'net/smtp'

Net::SMTP.start("your-isp-smtp-server.com") do |smtp|
  smtp.sendmail(email_text, from_addr, to_addr)
end 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Adam Reed
Sent: Thursday, March 01, 2007 2:04 PM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] Using Ruby for email notification?

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 <[EMAIL PROTECTED]>
To: Donald Duck <[EMAIL PROTECTED]>
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
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to