[英]How can I read my emails with clojure?
I want to parse messages from my IMAP inbox with clojure. 我想用clojure解析来自我的IMAP收件箱的邮件。
I know there is clojure-mail library, but I do not have a gmail account. 我知道有clojure邮件库,但我没有Gmail帐户。 Thanks! 谢谢!
The Apache Commons IMAP client library is a reasonable choice. Apache Commons IMAP客户端库是一个合理的选择。 The core of their example program is trivially replicated in well under 20 lines of Clojure, if one doesn't bother with failure handling: 他们的示例程序的核心很容易在20行以下的Clojure中复制,如果一个人不打扰故障处理:
(ns mail-client.core
(:import [org.apache.commons.net PrintCommandListener]
[org.apache.commons.net.imap IMAPClient]))
(defn get-mail [server username password]
(doto (IMAPClient.)
(.setDefaultTimeout 60000)
(.addProtocolCommandListener (PrintCommandListener. System/out true))
(.connect server)
(.login username password)
(.setSoTimeout 6000)
(.capability)
(.select "inbox")
(.examine "inbox")
(.status "inbox" (into-array String ["MESSAGES"]))
(.logout)
(.disconnect)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.