core.utils.fetchers.POP3Fetcher module¶
Module with the POP3_SSL_Fetcher class.
- class core.utils.fetchers.POP3Fetcher.POP3Fetcher(account)[source]¶
Bases:
BaseFetcher,SafePOPMixinMaintains a connection to the POP server and fetches data using
poplib.Opens a connection to the POP server on construction and is preferably used in a ‘with’ environment. Allows fetching of mails and mailboxes from an account on an POP host.
Since POP does not have any mailboxes, none of the methods should raise a MailboxError.
- Parameters:
account (Account)
- PROTOCOL = 'POP3'¶
Name of the used protocol, refers to
MailFetchingProtocols.POP3.
- AVAILABLE_FETCHING_CRITERIA: tuple[str, ...] = (EmailFetchingCriterionChoices.ALL,)¶
Tuple of all criteria available for fetching. Refers to
MailFetchingCriteria. Must be immutable!
- __init__(account)[source]¶
Constructor, starts the POP connection and logs into the account.
- Parameters:
account (
Account) – The model of the account to be fetched from.- Return type:
None
- connect_to_host()[source]¶
Opens the connection to the POP server using the credentials from
account.- Raises:
MailAccountError – If an error occurs or a bad response is returned.
- Return type:
- test(mailbox=None)[source]¶
Tests the connection to the mailserver and, if a mailbox is provided, whether messages can be listed.
- Parameters:
mailbox (
Mailbox|None) – The mailbox to be tested. Default is None.- Raises:
ValueError – If the
mailboxdoes not belong toself.account.MailAccountError – If the test fails because an error occurs or a bad response is returned.
- Return type:
- fetch_emails(mailbox, criterion=<core.utils.FetchingCriterion.FetchingCriterion object>)[source]¶
Fetches and returns all maildata from the server.
- Parameters:
mailbox (
Mailbox) – Database model of the mailbox to fetch data from.criterion (
FetchingCriterion) – POP only supports ALL lookups. Defaults toeonvelope.MailFetchingCriteria.ALL. This arg ensures compatibility with the other fetchers.
- Yields:
Mails in the mailbox.
- Raises:
ValueError – If the
mailboxdoes not belong toself.account. Ifcriterionis noteonvelope.MailFetchingCriteria.ALL.MailAccountError – If an error occurs or a bad response is returned.
- Return type:
- fetch_mailboxes()[source]¶
Returns the data of the mailboxes. For POP3 there is only one mailbox named ‘INBOX’.
Note
This method is built to match the fetcherclasses interface.
- restore(email)[source]¶
Places an email in its mailbox.
Note
POP doesn’t offer an action to upload emails.
- Parameters:
email (
Email) – The email to restore.- Raises:
NotImplementedError – POP can’t restore emails.
- Return type: