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(
              host='imap.gmail.com',
              username='imapy@gmail.com',
              password='secret',
              ssl=True)

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('boss@email.com').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'])

Logout

>>> box.logout()

Installation

To install Imapy, simply:

$ pip install imapy

TO-DO

  • Create examples in separate folder

  • Better documentation

Project details


Download files

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

Source Distribution

imapy-1.0.1.tar.gz (22.6 kB view details)

Uploaded Source

File details

Details for the file imapy-1.0.1.tar.gz.

File metadata

  • Download URL: imapy-1.0.1.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for imapy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9a2f101c3019e08c5998c67e23cc67ce257a4232489b949b38437646a1996dfc
MD5 ea85d823b6073a6a8bf00fad7455d049
BLAKE2b-256 7900e995ab2c645d6fd21c5c99b271f1237e2970061a537fa2a4396bbc5e1c70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page