Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Apr 6, 2009
0 parents commit 4e793e2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions importer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env ruby
require "tmail"
require "makura"

maildir = File.expand_path(ARGV[1] || "~/Mail")
server = Makura::Server.new
database = server.database("maildir")
headers = %w(From To Subject Date Message-Id In-Reply-To List-Id).map(&:downcase)

TMail::Maildir.new(maildir).each { |mail|
begin
mail = TMail::Mail.new(mail)
doc = mail.keys.select { |k| headers.include?(k) }.inject({}) { |doc, header|
doc.update(header => mail[header].to_s, "body" => mail.body)
}
database.save(doc)
rescue => boom
$stderr.puts boom.message
next
end
}

0 comments on commit 4e793e2

Please sign in to comment.