Skip to main content

Imap for humans

Project description

Imapy is an MIT Licensed IMAP library, written in Python. It makes processing emails in your email box easy.

Most existing Python modules for dealing with IMAP are extremely low-level. They require the programmer to know the intricacies of IMAP protocol and differences in IMAP server behaviour so that even simple tasks require writing hundred lines of code.

Imapy changes that.

>>> box = imapy.connect(

Get all folder names:

>>> names = box.folders()

Get last 5 emails in ‘Inbox’ folder:

>>> emails = box.folder('Inbox').emails(-5)

Get unseen emails with Awesome in subject:

>>> q = Q()
>>> emails = box.folder('Inbox').emails(
>>>     q.subject('Awesome').unseen()
>>> )

Move messages sent by your boss to “Important” folder and mark them ‘Flagged’ and ‘Unseen’:

>>> q = Q()
>>> emails = box.folder('Inbox').emails(
>>>     q.sender('').unseen()
>>> )
>>> for email in emails:
>>>     email.move('Important').mark(['Flagged', 'Unseen'])

Print some email details:

>>> for email in emails:
>>>    print(email['from'], email['subject'])

Process all emails in ‘Inbox’ folder:

>>> status = box.folder('Inbox').info()
>>> total = status['total']
>>> for t in range(1, total + 1):
>>>     email = box.folder('Inbox').email(t)
>>>     print(email['subject'])


>>> box.logout()

You can see more examples here


To install Imapy, simply:

$ pip install imapy


Notes & TODO

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
imapy-1.1.1.tar.gz (23.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page