Created
January 4, 2010 13:48
-
-
Save snaka/268520 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE: | |
# echo "ほげ" | ruby sendmail.rb smtp.fuga.com [email protected] | |
# | |
require 'kconv' | |
require 'net/smtp' | |
my_server = ARGV[0] | |
my_address = ARGV[1] | |
mail_body =<<EOM | |
From: Auto downloader <#{my_address}> | |
To: Administrator <#{my_address}> | |
Subject: Batch log (#{Time.now.strftime("%Y-%m-%d %H:%M")}) | |
Date: #{Time.now.strftime "%a, %d %b %Y %X +0900"} | |
Message-Id: <#{Time.now.to_i}> | |
#{STDIN.read.tojis} | |
-- | |
from Batch program at #{Time.now.strftime "%a, %d %b %Y %X +0900"} | |
EOM | |
Net::SMTP.start( my_server, 25 ) {|smtp| | |
smtp.send_mail mail_body.tojis, my_address, my_address | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment