Package: easyimap
About this moduleSimple imap wrapper.Example to useconnectfunction create IMAP4_SSL instance by default:>>> import easyimap
>>> host = "imap.gmail.com"
>>> user = "me@example.com"
>>> password = "hogehogehogehoge"
>>> mailbox = "secret"
>>> imapper = easyimap.connect(host, user, password, mailbox)connectfunction also create IMAP4 instance by passingsslargument:>>> import easyimap
>>> host = "imap.gmail.com"
>>> user = "me@example.com"
>>> password = "hogehogehogehoge"
>>> mailbox = "secret"
>>> imapper = easyimap.connect(host, user, password, mailbox, ssl=False, port=143)This imapper can list up latest n mail bylistupmethod.
By default, This invokefetchfrom IMAP4_SSL instance with ‘(UID RFC822)’.:>>> mail1, mail2 = imapper.listup(2)
>>> mail1.uid
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 byunseenmethod:>>> 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, callquitmethod:>>> imapper.quit()Basic APIeasyimap.connect(host, user, password, mailbox=’INBOX’, timeout=15, ssl=True, port=993, **kwargs)Create IMAP4(_SSL) wrapper.If you want to keep read/unread status, Please pass optionalread_only=Trueargument.kwargs are read from Imapper’s constructor. Plz read source code.Imapperlistids(limit=10, criterion=None)Returns list of available email ids.listup(limit=10, criterion=None, include_raw=False)Returns list of mail_object.unseen(limit=10)Returns list of mail_object.mail(uid, include_raw=False)Returns MailObj.change_mailbox(mailbox)Change mailbox.quit()Close and Logout.MailObjectuidReturns UID(type: int).rawif you fetched email with include_raw option, this returns raw Data:>>> [(id1, mail1), (id2, mail2)] = imapper.listup(2, include_raw)
>>> data = mail1.rawtitleReturns string of ‘Subject’ header.senderReturns string of ‘Sender’ header.from_addrReturns string of ‘From’ header.toReturns string of ‘To’ header.dateReturns string of ‘Date’ header.bodyReturns string of Body.content_typeReturns string of ‘Content-Type’ header.content_transfer_encodingReturns string of ‘Content-Transfer-Encoding’ header.referencesReturns string of ‘References’ header.in_reply_toReturns string of ‘In-Reply-To’ header.reply_toReturns string of ‘Reply-To’ header.return_pathReturns string of ‘Return-Path’ header.mime_versionReturns string of ‘MIME-Version’ header.message_idReturns string of ‘Message-ID’ header.attachmentsReturns list of tuples(‘attached file name’, MailObj).Recent Change0.6.3Add support for python-3.5.Fixed a bug in decoding an attached plain text.0.6.2Fixed a bug in header/body encoding0.6.1Fixed a bug in _decode_header function0.6.0Add support for Python-3.4.Backward incompatible changesModifylistupto return list of mailobj.Rename many properties to underbar separated format.