Platypush documentation
mail
- class platypush.backend.mail.MailBackend(mailboxes: List[Dict[str, Any]], timeout: Optional[int] = 60, poll_seconds: Optional[int] = 60, **kwargs)[source]
Bases:
Backend
This backend can subscribe to one or multiple mail servers and trigger events when new messages are received or messages are marked as seen.
It requires at least one plugin that extends
platypush.plugins.mail.MailInPlugin
(e.g.mail.imap
) to be installed.Triggers:
platypush.message.event.mail.MailReceivedEvent
when a new message is received.platypush.message.event.mail.MailSeenEvent
when a message is marked as seen.platypush.message.event.mail.MailFlaggedEvent
when a message is marked as flagged/starred.platypush.message.event.mail.MailUnflaggedEvent
when a message is marked as unflagged/unstarred.
- __init__(mailboxes: List[Dict[str, Any]], timeout: Optional[int] = 60, poll_seconds: Optional[int] = 60, **kwargs)[source]
- Parameters:
mailboxes –
List of mailboxes to be monitored. Each mailbox entry contains a
plugin
attribute to identify theplatypush.plugins.mail.MailInPlugin
plugin that will be used (e.g.mail.imap
) and the arguments that will be passed toplatypush.plugins.mail.MailInPlugin.search_unseen_messages()
. Thename
parameter can be used to identify this mailbox in the relevant events, otherwiseMailbox #{id}
will be used as a name. Example configuration:backend.mail: mailboxes: - plugin: mail.imap name: "My Local Server" username: me@mydomain.com password: my-imap-password server: localhost ssl: true folder: "All Mail" - plugin: mail.imap name: "GMail" username: me@gmail.com password: my-google-password server: imap.gmail.com ssl: true folder: "INBOX"
If you have a default configuration available for a mail plugin you can implicitly reuse it without replicating it here. Example:
mail.imap: username: me@mydomain.com password: my-imap-password server: localhost ssl: true backend.mail: mailboxes: # The mail.imap default configuration will be used - plugin: mail.imap name: "My Local Server" folder: "All Mail"
poll_seconds – How often the backend should check the mail (default: 60).
timeout – Connect/read timeout for a mailbox, in seconds (default: 60).
- class platypush.backend.mail.Mailbox(plugin: platypush.plugins.mail.MailInPlugin, name: str, args: dict)[source]
Bases:
object
- class platypush.backend.mail.MailboxStatus(**kwargs)[source]
Bases:
Base
Models the MailboxStatus table, containing information about the state of a monitored mailbox.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.