From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philippe M. Coatmeur Newsgroups: gmane.emacs.help Subject: How does imap.el work? Date: Sat, 16 Jun 2012 17:08:42 +0000 Organization: A noiseless patient Spider Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: dough.gmane.org 1339863618 27284 80.91.229.3 (16 Jun 2012 16:20:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 16 Jun 2012 16:20:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 16 18:20:15 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SfvjQ-0006eL-OZ for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Jun 2012 18:20:12 +0200 Original-Received: from localhost ([::1]:54002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfvjQ-0004Hf-6R for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Jun 2012 12:20:12 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news2.euro.net!newsfeed.freenet.ag!newsfeed.kamp.net!newsfeed.kamp.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 93 Injection-Info: mx04.eternal-september.org; posting-host="xqiWf82qe/GVUmt8W5Fgew"; logging-data="3156"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ECFNCF+OTG2a5YMurNf6cX4vFZIJsIs4=" User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/24.1 Mule/6.0 (HANACHIRUSATO) Cancel-Lock: sha1:15J9cWh3lRmIxtC7T3IskR+vkUk= Original-Xref: usenet.stanford.edu gnu.emacs.help:192872 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85268 Archived-At: Hi ; I'm trying to understand how to use imap.el (part of GNU emacs, I'm using 24.1.50) and got it to do pretty nifty tricks, like -Connect to my imap server (both my own dovecot and gmail) -List mailboxes and select one -List sub-mailboxes in said selected mailbox -Get a message by it id (see a glimpse of my experiments at the end of this message) But what I really want to do is get a list of unread (IMAP flag "UNSEEN") mails. Now on top of the lib, in the comments, is a list of all available commands : ;; Global commands: ;; ;; imap-open, imap-opened, imap-authenticate, imap-close, ;; imap-capability, imap-namespace, imap-error-text ;; ;; Mailbox commands: ;; ;; imap-mailbox-get, imap-mailbox-map, imap-current-mailbox, ;; imap-current-mailbox-p, imap-search, imap-mailbox-select, ;; imap-mailbox-examine, imap-mailbox-unselect, imap-mailbox-expunge ;; imap-mailbox-close, imap-mailbox-create, imap-mailbox-delete ;; imap-mailbox-rename, imap-mailbox-lsub, imap-mailbox-list ;; imap-mailbox-subscribe, imap-mailbox-unsubscribe, imap-mailbox-status ;; imap-mailbox-acl-get, imap-mailbox-acl-set, imap-mailbox-acl-delete ;; ;; Message commands: ;; ;; imap-fetch-asynch, imap-fetch, ;; imap-current-message, imap-list-to-message-set, ;; imap-message-get, imap-message-map ;; imap-message-envelope-date, imap-message-envelope-subject, ;; imap-message-envelope-from, imap-message-envelope-sender, ;; imap-message-envelope-reply-to, imap-message-envelope-to, ;; imap-message-envelope-cc, imap-message-envelope-bcc ;; imap-message-envelope-in-reply-to, imap-message-envelope-message-id ;; imap-message-body, imap-message-flag-permanent-p ;; imap-message-flags-set, imap-message-flags-del ;; imap-message-flags-add, imap-message-copyuid ;; imap-message-copy, imap-message-appenduid ;; imap-message-append, imap-envelope-from ;; imap-body-lines ;; ;; It is my hope that these commands should be pretty self ;; explanatory for someone that know IMAP. All functions have ;; additional documentation on how to invoke them. But no, not "All functions have additional documentation on how to invoke them.", only a handful have. Go ahead, try to C-h f with point over imap-mailbox-get, or imap-search. It also says "these commands should be pretty self explanatory for someone that know IMAP" and that is right, I don't *know* IMAP like I know, say my daughter. But still, I implemented two (basic) imap > clients before, one in PHP and one in Perl (using Mail::IMAPClient) but both provided thicker abstraction layers than what imap.el does. I also read http://www.dovecot.org/imap-client-coding-howto.html and http://www.imapwiki.org/ClientImplementation but again, I miss the link between those server commands and client implementation. If anybody know how to get a list of unread messages in a given mailbox, a "message" being the timestamp, the "from" and the "subject" using imap.el it would really point me in the right direction... APPENDIX : Tries (require 'imap) (defun my-test-imap () (switch-to-buffer (imap-open "mail.server.net")) (with-current-buffer (current-buffer) (imap-authenticate "user" "passwd") (setq mailbox (imap-mailbox-list "INBOX")) (imap-mailbox-select "Inbox") (imap-mailbox-get 'uidvalidity) ;; Returns nothing (setq status (imap-mailbox-status "Inbox" 'unseen)) ;; Returns even less (imap-mailbox-examine "Inbox") ;; This does nothing too (imap-search "ALL") ;; Everything else works (setq my-msg (imap-fetch 1 "RFC822" 'RFC822)) (message "HOY! %s" my-msg) (imap-close) )) (defun test-imap-cmd () (interactive) (test-imap)) Philippe