#!/usr/bin/ruby require "net/imap" server = ARGV[0] user = ARGV[1] password = ARGV[2] from = ARGV[3] writefile = ARGV[4] #Net::IMAP.debug = true imap = Net::IMAP.new(server) imap.login(user, password) imap.select "inbox" n = imap.search(%W/FROM #{from}/).last if n msgs = imap.fetch n, "body[1.text]" c = msgs[0].attr["BODY[1.TEXT]"] b,w = c.split("\n",2) if b.chomp == "spelling" words = w.split "\n" end end imap.logout file = File.open(writefile, "w") file.puts words file.close