High-Level IMAP library for Python
Asked Answered
P

5

8

Is there a high-level IMAP library for Python?

With high-level I mean, that I do not want a library where I can issue basic IMAP commands (like Python's own imaplib). What I want, is library that cares about most of the IMAP details and gives me a more generic interface with objects for folders/mailboxes and messages. Additionally, it would be nice if it supports the disconnected mode of operation (offline mode) transparently.

Psychosocial answered 10/6, 2012 at 12:7 Comment(2)
That's not really an IMAP library anymore, but a mail client.Welkin
Yes, that's basically the backend of a mail client.Psychosocial
Y
0

To answer your question: What you're looking for doesn't exist in the wild AFAIK.

Short of that, have you considered calling context.io from Python?

Yan answered 14/10, 2012 at 5:20 Comment(1)
context.io doesn't fit my original need, but it seems cool. I've never heard of it before, I'll look into it.Psychosocial
I
5

You may use imap_tools package: https://pypi.org/project/imap-tools/

Features:

  • Basic message operations: fetch, uids, numbers
  • Parsed email message attributes
  • Query builder for searching emails
  • Actions with emails: copy, delete, flag, move, append
  • Actions with folders: list, set, get, create, exists, rename, subscribe, delete, status
  • IDLE commands: start, poll, stop, wait
  • Exceptions on failed operations
  • No external dependencies
Imminent answered 9/10, 2019 at 12:51 Comment(0)
B
3

I know I'm late to the discussion here, but IMAPClient looks like it could be what a you're looking for. It's more high-level than imaplib (and is built on top of imaplib). I'm just starting to use it for a project myself so have no experience in it yet, but looks good.

Brabble answered 10/9, 2013 at 17:24 Comment(0)
C
0

IMAP is already pretty high level and gives you an interface to mailboxes, messages, and all the goods of your email. You might want to checkout: http://verpa.wordpress.com/2010/01/23/python-gmail-imap-part-1/ http://sourceforge.net/projects/libgmail/

which further simplifies IMAP interaction for Gmail.

Christmastide answered 4/8, 2012 at 7:42 Comment(0)
Y
0

To answer your question: What you're looking for doesn't exist in the wild AFAIK.

Short of that, have you considered calling context.io from Python?

Yan answered 14/10, 2012 at 5:20 Comment(1)
context.io doesn't fit my original need, but it seems cool. I've never heard of it before, I'll look into it.Psychosocial
K
0

This is kind of a non-answer. I don't know a good python based solution. However, this is where anyone looking for such a thing will likely find themselves, so it is my hope that this answer may lead to the creation of a good python solution.

My solution after writing about 150 lines of python code, reading more of the IMAP RFCs than I have needed at any time in the last 20 years and nearly getting it working came through the discovery of imapfilter. It's scripted with lua, which I'd never used before, but within a couple of hours I had a working script just 20 lines long.

It's not hard to imagine reasons why you'd want the full power of python rather than just what imapfilter gives you, but imapfilter might do what you need, and it does provide a pretty decent starting point for imagining what a high level python library should look like.

Keijo answered 21/8, 2015 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.