james_b
2/21/2006 10:16:00 PM
John N. Alegre wrote:
> I want to send some mail using ruby as the CGI.
>
> I have no trouble creating the parsing code.
>
> What I need is a quick easy way to send the mail.
>
I have a script that checks my library for DVDs, and mails my cell phone
when found. Here's the mailing code:
require 'net/smtp'
def sa2( search, url )
send_to_domain = "some-domain.com"
send_to = "mobile@some-domain.com"
send_from_domain = "from-domain.com"
send_from = "james@from-domain.com"
msgstr = "From: Library Checker <#{send_from}>
To: #{send_to} <#{send_to}>
Subject: DVD search notice : #{search} #{Time.new.to_s}
Date: #{Time.new().to_s}
Message-Id: <#{Time.new().to_i}@#{send_from_domain}>
This is a library search alert , sent on #{Time.new().to_s}.\n\n#{msg}"
Net::SMTP.start( "#{send_to_domain}", 25, send_from_domain ) { |smtp|
smtp.send_message( msgstr, send_from, send_to )
}
end
# the end
Sloppy but functional. Beats Blockbuster.
--
James Britt
“Design depends largely on constraints.”
— Charles Eames