summaryrefslogtreecommitdiff
path: root/spelling-rbead
blob: 4ea24c0db028e6904412c7ef522201b823f531ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/ruby

require "net/imap"
require "base64"
server = ARGV[0]
user = ARGV[1]
password = Base64.decode64 ARGV[2]
from = ARGV[3]

#Net::IMAP.debug = true
imap = Net::IMAP.new(server)
imap.login(user, password)
imap.select "inbox"
n = imap.search("FROM \"#{from}\" SUBJECT \"Spelling:\"").last
if n
  msgs = imap.fetch n, "body[1.text]"
  c = msgs[0].attr["BODY[1.TEXT]"]
  words = c.split("\n")
end
imap.logout

puts words