arjuna.tpi.emailauto.mailbox module

class arjuna.tpi.emailauto.mailbox.MailBox(*, server, name='INBOX', readonly=False)

Bases: object

Represents a named mailbox like Inbox in the email server for a user account.

Keyword Arguments
  • server – Arjuna’s Email Server object.

  • name – Name of the mailbox. Default is Inbox.

  • readonly – If True, messages can bot be deleted in the mailbox. Default is False.

property count

Current number of emails present in the mailbox.

email_at(ordinal, _reload=True)

Email at an ordinal/position - human counted, 1 is the oldest email position.

emails(*, sender=None, subject=None, content=None, max=5, latest=True)

Get Current Emails as per provided optional filters.

Keyword Arguments
  • sender – Filter with Email address from which email is received.

  • subject – Filter with Case-insensitive sub-string in subject line.

  • content – Filter with Case-insensitive sub-string in content.

  • max – Maximum number of emails to be returned. Default is 5.

  • latest – If True, latest emails are considered. Default is True.

Note

If no email is found in current emails that meets the filtering criteria, an automatic wait loop triggers and this method works just like new_emails method in such a context. When the logic finds the first matching email, it tries to find more, else the wait loop is exited.

latest(*, sender=None, subject=None, content=None, max_wait=None)

Latest email received since the previous saved state (saved using save_state call), as per provided optional filters.

This is a shortcut method, and works same as providing max=1 to new_emails.

Keyword Arguments
  • sender – Filter with Email address from which email is received.

  • subject – Filter with Case-insensitive sub-string in subject line.

  • content – Filter with Case-insensitive sub-string in content.

  • max_wait – Maximum time in seconds to re-select mailbox or availablity of emails in the mailbox.

property name

Name of this mailbox.

new_emails(*, sender=None, subject=None, content=None, max=5, max_wait=None)

New emails received since the previous saved state (saved using save_state call), as per provided optional filters.

Keyword Arguments
  • sender – Filter with Email address from which email is received.

  • subject – Filter with Case-insensitive sub-string in subject line.

  • content – Filter with Case-insensitive sub-string in content.

  • max – Maximum number of emails to be returned. Default is 5.

  • max_wait – Maximum time in seconds to re-select mailbox or availablity of emails in the mailbox.

Note

The wait is not a static wait and comes into play if no email meets the filtering criteria. When the logic finds the first matching email, it tries to find more, else the wait loop is exited.

property readonly

Is it a readonly mailbox selection?

save_state()

Save current state information (like email count) before triggering a wait event in subsequent call.