#!/usr/bin/env ruby require 'net/smtp' def send(mail) unless(mail == '') mail.chomp! print '#' * 80 + ($c += 1).to_s + $/ + mail[0, 128], $/ + mail[-128, 128], $/ if(mail != '' and ARGV[4]) Net::SMTP.start(ARGV[1], 25) {|smtp| smtp.send_mail mail, ARGV[3], ARGV[2] sleep 1 } end end end raise 'Usage: import2gmail2 maildir host to_adr from_adr [exec]' unless(ARGV.length >= 4) maildir = ARGV[0] + '/' fns = [] Dir.new(maildir).each {|fn| fn =~ /^\d/ or next fns << fn } $c = 0; mail = '' fns.sort.each {|fn| mail = open(maildir + fn).read send(mail) }