Skip to content
Browse files

extra data support

  • Loading branch information...
1 parent e375931 commit 3eb49c767c2001010e899e0d1282a3d7c167cdfc @apage43 committed
Showing with 5 additions and 3 deletions.
  1. +2 −1 README.md
  2. +3 −2 src/couchmail.clj
View
3 README.md
@@ -21,4 +21,5 @@ Send email to be stored to couchdb in MIME to the couchmail.Store Nail with the
Example .fetchmailrc:
poll imap.mailserver.com protocol imap user "someguy@placeville.io" password "hunter2" mda "/usr/local/bin/ng couchmail.Store http://127.0.0.1:5984/mail" ssl
-
+couchmail.Store optionally excepts as a third parameter an aribtrary json blob to merge with imported mail. For example, to tag all mail from my work email account in a [mailbag](http://github.com/apage43/mailbag) bag, I can use a fetchmailrc line like this:
+ poll imap.mailserver.com protocol imap user "someguy@workplace.com" password "hunter2" mda "/usr/local/bin/ng couchmail.Store http://127.0.0.1:5984/mail '{\x22bags\x22:[\x22work\x22]}'" ssl
View
5 src/couchmail.clj
@@ -73,6 +73,7 @@
(defn Store-nailMain [ctx]
(let [args (seq (.getArgs ctx))
- dburl (if (= 1 (count args)) (first args) "http://127.0.0.1:5984/mail")]
- (http/post dburl {:body (json-str (simplify-message (create-message (.in ctx)))) :content-type :json})
+ dburl (if (< 0 (count args)) (first args) "http://127.0.0.1:5984/mail")
+ merged (if (< 1 (count args)) (read-json (second args)) {})]
+ (http/post dburl {:body (json-str (merge merged (simplify-message (create-message (.in ctx))))) :content-type :json})
(println "OK")))

0 comments on commit 3eb49c7

Please sign in to comment.
Something went wrong with that request. Please try again.