class documentation

class IMAP4:

Constructor: IMAP4(host, port)

View In Hierarchy

A minimal IMAP4 client for MicroPython.

Method __init__ Connect to an IMAP server over SSL.
Method login Authenticate with the server.
Method logout Close the IMAP session.
Method select Select a mailbox.
Method uid_fetch Fetch a body part by UID.
Method uid_search Search by UID.
Method uid_store Set flags on a message by UID.
Method _cmd Send a tagged IMAP command and return its tag.
Method _read_exact Read exactly n bytes from the socket.
Method _read_line Read a single line from the socket.
Method _read_literal Read a literal, keeping only the first max_literal bytes.
Method _response Read responses until the tagged response for tag.
Instance Variable _sock Undocumented
Instance Variable _tag Undocumented
def __init__(self, host, port=993):

Connect to an IMAP server over SSL.

Parameters
host:strThe server hostname.
port:intThe server port. Defaults to 993.
def login(self, username, password):

Authenticate with the server.

Parameters
username:strThe login username.
password:strThe login password.
Returns
boolTrue on success.
def logout(self):

Close the IMAP session.

def select(self, mailbox='INBOX'):

Select a mailbox.

Parameters
mailbox:strThe mailbox name. Defaults to "INBOX".
Returns
tuple(ok, response data).
def uid_fetch(self, uid, parts, max_literal=0):

Fetch a body part by UID.

Parameters
uid:strThe message UID.
parts:strThe body part specifier.
max_literal:intMaximum literal bytes to keep. Defaults to 0.
Returns
bytes or NoneThe literal bytes.
def uid_search(self, criteria='UNSEEN'):

Search by UID.

Parameters
criteria:strThe search criteria. Defaults to "UNSEEN".
Returns
listUID strings.
def uid_store(self, uid, flags='(\\Seen)'):

Set flags on a message by UID.

Parameters
uid:strThe message UID.
flags:strThe flags to set. Defaults to "(Seen)".
Returns
boolTrue on success.
def _cmd(self, command):

Send a tagged IMAP command and return its tag.

Parameters
command:strThe IMAP command.
Returns
bytesThe command tag.
def _read_exact(self, n):

Read exactly n bytes from the socket.

Parameters
n:intThe number of bytes to read.
Returns
bytesThe bytes read.
def _read_line(self):

Read a single line from the socket.

def _read_literal(self, size, max_literal=0):

Read a literal, keeping only the first max_literal bytes.

Parameters
size:intThe literal size.
max_literal:intMaximum bytes to keep. Defaults to 0.
Returns
bytesThe literal bytes.
def _response(self, tag, max_literal=0):

Read responses until the tagged response for tag.

Parameters
tag:bytesThe command tag.
max_literal:intMaximum literal bytes to keep. Defaults to 0.
Returns
tuple(status, data); literals are stored as ('literal', bytes).
_sock =

Undocumented

_tag: int =

Undocumented