class POP3(basic.LineOnlyReceiver, policies.TimeoutMixin): (source)
Known subclasses: twisted.mail.protocols.VirtualPOP3
Implements interfaces: twisted.internet.interfaces.IProducer
A POP3 server protocol.
Method | authenticate |
Perform APOP authentication. |
Method | authenticate |
Perform authentication for a username/password login. |
Method | connection |
Clean up when the connection has been lost. |
Method | connection |
Send a greeting to the client after the connection has been made. |
Method | do_ |
Handle an APOP command. |
Method | do_ |
Handle an AUTH command. |
Method | do_ |
Handle a CAPA command. |
Method | do_ |
Handle a DELE command. |
Method | do_ |
Handle a LAST command. |
Method | do_ |
Handle a LIST command. |
Method | do_ |
Handle a NOOP command. |
Method | do_ |
Handle a PASS command. |
Method | do_ |
Handle a QUIT command. |
Method | do_ |
Handle a RETR command. |
Method | do_ |
Handle an RPOP command. |
Method | do_ |
Handle a RSET command. |
Method | do_ |
Handle a STAT command. |
Method | do_ |
Handle a TOP command. |
Method | do_ |
Handle a UIDL command. |
Method | do_ |
Handle a USER command. |
Method | fail |
Send a response indicating failure. |
Method | finished |
Send the termination sequence. |
Method | generate |
Generate an APOP challenge. |
Method | line |
Pass a received line to a state machine function. |
Method | list |
Return a list of server capabilities suitable for use in a CAPA response. |
Method | process |
Dispatch a command from the client for handling. |
Method | state_ |
Handle received lines for the AUTH state in which an authentication challenge response from the client is expected. |
Method | state_ |
Handle received lines for the COMMAND state in which commands from the client are expected. |
Method | stop |
Stop producing data. |
Method | success |
Send a response indicating success. |
Method | transform |
Transform a chunk of a message to POP3 message format. |
Constant | AUTH |
Undocumented |
Instance Variable | blocked |
A list of blocked commands. While a response to a command is being generated by the server, other commands are blocked. When no command is outstanding, blocked is set to none. Otherwise, it contains a list of information about blocked commands... |
Instance Variable | factory |
A server factory which provides an interface for querying capabilities of the server. |
Instance Variable | magic |
An APOP challenge. If not set, an APOP challenge string will be generated when a connection is made. |
Instance Variable | mbox |
The mailbox for the authenticated user. |
Instance Variable | portal |
A portal for authentication. |
Instance Variable | schedule |
A callable that arranges for an iterator to be cooperatively iterated over along with all other iterators which have been passed to it such that runtime is divided between all of them. It returns a deferred which fires when the iterator finishes. |
Instance Variable | state |
The state which indicates what type of messages are expected from the client. Valid states are 'COMMAND' and 'AUTH' |
Instance Variable | time |
The number of seconds to wait for a command from the client before disconnecting. |
Method | _cb |
Complete successful authentication. |
Method | _coiterate |
Direct the output of an iterator to the transport and arrange for iteration to take place. |
Method | _eb |
Handle an expected authentication failure. |
Method | _eb |
Handle an unexpected authentication failure. |
Method | _get |
Retrieve the size and contents of a message. |
Method | _long |
Stop timeouts and block further command processing while a long operation completes. |
Method | _send |
Send the contents of a message. |
Method | _unblock |
Process as many blocked commands as possible. |
Instance Variable | _auth |
Authorization credentials. |
Instance Variable | _highest |
The 1-based index of the highest message retrieved. |
Instance Variable | _on |
The function to be executed when the connection is lost. |
Instance Variable | _user |
The username sent with the USER command. |
Inherited from LineOnlyReceiver
:
Method | data |
Translates bytes into lines, and calls lineReceived. |
Method | line |
Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way. |
Method | send |
Sends a line to the other end of the connection. |
Constant | MAX |
The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped). Default is 16384. |
Class Variable | delimiter |
The line-ending delimiter to use. By default this is b'\r\n'. |
Instance Variable | _buffer |
Undocumented |
Inherited from Protocol
(via LineOnlyReceiver
):
Method | log |
Return a prefix matching the class name, to identify log messages related to this protocol instance. |
Inherited from BaseProtocol
(via LineOnlyReceiver
, Protocol
):
Method | make |
Make a connection to a transport and a server. |
Instance Variable | connected |
Undocumented |
Instance Variable | transport |
Undocumented |
Inherited from TimeoutMixin
(via LineOnlyReceiver
, Protocol
, BaseProtocol
):
Method | call |
Wrapper around reactor.callLater for test purpose. |
Method | reset |
Reset the timeout count down. |
Method | set |
Change the timeout period |
Method | timeout |
Called when the connection times out. |
Method | __timed |
Undocumented |
Instance Variable | __timeout |
Undocumented |
twisted.mail.protocols.VirtualPOP3
Perform APOP authentication.
Parameters | |
user:bytes | The name of the user attempting to log in. |
digest:bytes | The challenge response. |
Returns | |
Deferred which successfully results in 3-tuple of (1) IMailbox , (2) IMailbox provider, (3) no-argument callable | A deferred which fires when authentication is complete. If successful, it returns an IMailbox interface, a mailbox, and a function to be invoked with the session is terminated. If authentication fails, the deferred fails with an UnathorizedLogin error. |
Raises | |
cred.error.UnauthorizedLogin | When authentication fails. |
twisted.mail.protocols.VirtualPOP3
Perform authentication for a username/password login.
Parameters | |
user:bytes | The name of the user attempting to log in. |
password:bytes | The password to authenticate with. |
Returns | |
Deferred which successfully results in 3-tuple of (1) IMailbox , (2) IMailbox provider, (3) no-argument callable | A deferred which fires when authentication is complete. If successful, it returns a pop3.IMailbox interface, a mailbox, and a function to be invoked with the session is terminated. If authentication fails, the deferred fails with an UnathorizedLogin error. |
Raises | |
cred.error.UnauthorizedLogin | When authentication fails. |
Clean up when the connection has been lost.
Parameters | |
reason:Failure | The reason the connection was terminated. |
Handle an APOP command.
Perform APOP authentication and complete the authorization process with the _cbMailbox
callback function on success or the _ebMailbox
and _ebUnexpected
errback functions on failure.
Parameters | |
user:bytes | A username. |
digest:bytes | An MD5 digest string. |
Handle an AUTH command.
If the AUTH extension is not supported, send an error response. If an authentication mechanism was not specified in the command, send a list of all supported authentication methods. Otherwise, send an authentication challenge to the client and transition to the AUTH state.
Parameters | |
args:bytes or None | The name of an authentication mechanism. |
Handle a DELE command.
Mark a message for deletion and issue a successful response.
Parameters | |
i:int | A 1-based message index. |
Handle a PASS command.
If a USER command was previously received, authenticate the user and complete the authorization process with the _cbMailbox
callback function on success or the _ebMailbox
and _ebUnexpected
errback functions on failure. If a USER command was not previously received, send an error response.
Parameters | |
password:bytes | A password. |
*words:tuple of bytes | Other parts of the password split by spaces. |
Handle a QUIT command.
Remove any messages marked for deletion, issue a successful response, and drop the connection.
Handle an RPOP command.
RPOP is not supported. Send an error response.
Parameters | |
user:bytes | A username. |
Handle a STAT command.
Returns | |
Deferred | A deferred which triggers after the response to the STAT command has been issued. |
Handle a USER command.
Save the username and send a successful response prompting the client for the password.
Parameters | |
user:bytes | A username. |
Send a response indicating failure.
Parameters | |
message:stringifyable object | An object whose string representation should be included in the response. |
Handle received lines for the AUTH state in which an authentication challenge response from the client is expected.
Transition back to the COMMAND state. Check the credentials and complete the authorization process with the _cbMailbox
callback function on success or the _ebMailbox
and _ebUnexpected
errback functions on failure.
Parameters | |
line:bytes | The challenge response. |
Handle received lines for the COMMAND state in which commands from the client are expected.
Parameters | |
line:bytes | A received command. |
Stop producing data.
This tells a producer that its consumer has died, so it must stop producing data for good.
Send a response indicating success.
Parameters | |
message:stringifyable object | An object whose string representation should be included in the response. |
A list of blocked commands. While a response to a command is being generated by the server, other commands are blocked. When no command is outstanding, blocked is set to none. Otherwise, it contains a list of information about blocked commands. Each list entry consists of the command and the arguments to the command.
An APOP challenge. If not set, an APOP challenge string will be generated when a connection is made.
A callable that arranges for an iterator to be cooperatively iterated over along with all other iterators which have been passed to it such that runtime is divided between all of them. It returns a deferred which fires when the iterator finishes.
The state which indicates what type of messages are expected from the client. Valid states are 'COMMAND' and 'AUTH'
Complete successful authentication.
Save the mailbox and logout function for the authenticated user and send a successful response to the client.
Parameters | |
result:tuple | The first item of the tuple is a zope.interface.Interface which is the interface supported by the avatar. The second item of the tuple is a IMailbox provider which is the mailbox for the authenticated user. The third item of the tuple is a no-argument callable which is a function to be invoked when the session is terminated. |
user:bytes | The user being authenticated. |
Handle an expected authentication failure.
Send an appropriate error response for a LoginDenied
or LoginFailed
authentication failure.
Parameters | |
failure:Failure | The authentication error. |
Handle an unexpected authentication failure.
Send an error response for an unexpected authentication failure.
Parameters | |
failure:Failure | The authentication error. |
Stop timeouts and block further command processing while a long operation completes.
Parameters | |
d:Deferred | A deferred which triggers at the completion of a long operation. |
Returns | |
Deferred | A deferred which triggers after command processing resumes and timeouts restart after the completion of a long operation. |
Process as many blocked commands as possible.
If there are no more blocked commands, set up for the next command to be sent immediately.
Parameters | |
_:object | Ignored. |