Skip to content

Instantly share code, notes, and snippets.

@snaka
Created January 4, 2010 13:48
Show Gist options
  • Save snaka/268520 to your computer and use it in GitHub Desktop.
Save snaka/268520 to your computer and use it in GitHub Desktop.
# 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