---- mhc-alarm-mail ---- #!/usr/local/bin/ruby mail_address = 'hoge@exsample.co.jp' mail_address_from = 'foo@exsample.co.jp' MailServer = 'localhost' ## for --mail option MyHostName = 'localhost' ## for --mail option require 'mhc-schedule' require 'mhc-kconv' require 'net/smtp' $db = MhcScheduleDB .new() $alarm = MhcAlarm .new($db) $alarm .signal_connect('time-arrived'){|date, sch| header = "To: #{mail_address}\n" header += "Subject: アラーム (#{sch .subject})\n" header += "From: #{mail_address_from}\n" header += "\n" contents = "#{sch .dump_header}\n" contents = contents.gsub(/^X-SC-Cond:.*\n/, "") contents = contents.gsub(/^X-SC-Duration:.*\n/, "") contents = contents.gsub(/^X-SC-Priority:.*\n/, "") contents = contents.gsub(/^X-SC-Record-Id:.*\n/, "") contents = contents.gsub(/^X-SC-/, "") contents = contents.gsub(/^Mime-Version:.*\n/, "") contents = contents.gsub(/^Content.*\n/, "") message = MhcKconv::tomail(header + contents) Net::SMTPSession .start(MailServer, 25, MyHostName) {|server| server .sendmail(message, mail_address, [mail_address]) } } $alarm .check sleep ## wait forever. exit 0 ## unreached.