]> git.cworth.org Git - sup/blobdiff - lib/sup/imap.rb
Add store_message to IMAP, mbox and Maildir sources.
[sup] / lib / sup / imap.rb
index 4eb13f4ed619d3259df4894eec4a8b66c11c326e..6c04d885d5856a719ba46460b465f51186034a3e 100644 (file)
@@ -93,7 +93,7 @@ class IMAP < Source
   def == o; o.is_a?(IMAP) && o.uri == self.uri && o.username == self.username; end
 
   def load_header id
-    MBox::read_header StringIO.new(raw_header(id))
+    parse_raw_email_header StringIO.new(raw_header(id))
   end
 
   def load_message id
@@ -111,6 +111,14 @@ class IMAP < Source
   end
   synchronized :raw_header
 
+  def store_message date, from_email, &block
+    message = StringIO.new
+    yield message
+    message.string.gsub! /\n/, "\r\n"
+
+    safely { @imap.append mailbox, message.string, [:Seen], Time.now }
+  end
+
   def raw_message id
     unsynchronized_scan_mailbox
     get_imap_fields(id, 'RFC822').first.gsub(/\r\n/, "\n")