Giter Site home page Giter Site logo

easyimap's Introduction

About this module

Simple imap wrapper.

Example to use

connect function create IMAP4_SSL instance:

>>> import easyimap
>>> host = "imap.gmail.com"
>>> user = "[email protected]"
>>> password = "hogehogehogehoge"
>>> mailbox = "secret"
>>> imapper = easyimap.connect(host, user, password, mailbox)

This imapper can list up latest n mail by listup method:

>>> imapper.listup(2)
[(80, <easyimap.easyimap.MailObj object at 0x...>), (79, <easyimap.easyimap.MailObj object at 0x...)]
>>> [(id1, mail1), (id2, mail2)] = imapper.listup(2)
>>> id1
80
>>> mail1
<easyimap.easyimap.MailObj object at 0x...>
>>> type(mail1.body)
<type 'unicode'>
>>> type(mail1.title)
<type 'unicode'>
>>> type(mail1.date)
<type 'unicode'>
>>> type(mail1.sender)
<type 'unicode'>

You can check latest unseen mail by unseen method:

>>> imapper.unseen(2)
[(82, <easyimap.easyimap.MailObj object at 0x...>), (81, <easyimap.easyimap.MailObj object at 0x...)]

You can directly fetch email object with specific id:

>>> imapper.mail(80)
<easyimap.easyimap.MailObj object at 0x...>

You can download attachments:

>>> imapper.mail(80)
>>> (id, mail) = imapper.mail(80)
>>> for attachment in mail.attachment:
>>>     print attachment[0], attachment[1]

Finally, call quit method:

>>> imapper.quit()

Basic API

  • easyimap.connect(host, user, password, mailbox='INBOX', timeout=15)
    Create IMAP4_SSL wrapper.

Imapper

  • listup(limit=10)
    Returns list of tuples(email_id, mail_object).
  • unseen(limit=10)
    Returns list of typles(email_id, mail_object).
  • mail(id)
    Returns MailObj.
  • change_mailbox(mailbox)
    Change mailbox.
  • quit
    Close and Logout.

MailObject

  • title
    Returns string of 'Subject' header.
  • sender
    Returns string of 'From' header.
  • date
    Returns string of 'Date' header.
  • body
    Returns string of Body.
  • contenttype
    Returns string of 'Content-Type' header.
  • contenttransferencoding
    Returns string of 'Content-Transfer-Encoding' header.
  • references
    Returns string of 'References' header.
  • inrepplyto
    Returns string of 'In-Reply-To' header.
  • repplyto
    Returns string of 'Reply-To' header.
  • returnpath
    Returns string of 'Return-Path' header.
  • mimeversion
    Returns string of 'MIME-Version' header.
  • messageid
    Returns string of 'Message-ID' header.
  • attachments
    Returns list of tuples('attached file name', MailObj).

easyimap's People

Contributors

keitaoouchi avatar

Watchers

 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.