Giter Site home page Giter Site logo

imapy's Introduction

Imapy: Imap for Humans

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='[email protected]',
              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('[email protected]').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()

You can see more examples here

Installation

To install Imapy, simply:

$ pip install imapy

Miscellaneous

Notes & TODO

imapy's People

Contributors

vladimarius avatar page1990 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.