From: Philippe M. Coatmeur <philippe.coatmeur@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: How does imap.el work?
Date: Sat, 16 Jun 2012 17:08:42 +0000 [thread overview]
Message-ID: <lzmx43tc9x.wl%philippe.coatmeur@gmail.com> (raw)
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
reply other threads:[~2012-06-16 17:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lzmx43tc9x.wl%philippe.coatmeur@gmail.com \
--to=philippe.coatmeur@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.