gmailtool

API Documentation for the tool gmailtool

class gmailtool.mailstream.GmailMailStream(http, mailbox, cursor=None)[source]

Present the Gmail API as a mail stream which can be sequentially accessed by .read()

Initialize a Gmail mail stream object

Parameters:
  • http (http) – An oauthed http object from the google oauth system
  • mailbox (str) – The mailbox to read (e.g. example@gmail.com)
  • cursor (str) – The cursor data to load the current position in the inbox
cursor

str – JSON representation of the inbox cursor

read()[source]

Read a bunch of messages from gmail.

Each time read is called it will attempt advance one history at at time. If advancing the history was successful then a list of email messages that were added to the mailbox will be returned. If we are at the most current history for the inbox and thus history was not advanced then None is returned.

It is possible that an empty list is returned signifiying that history was advanced but no new emails were added in the new history. Call read() another time to advance further.

Returns:A list of email messasges in the next page of history. Returns None if we are already at the latest history and can not read any more
Return type:List of email message or None