class twisted.mail.imap4.IMAP4Server(basic.LineReceiver, policies.TimeoutMixin): (source)
Implements interfaces: twisted.mail.interfaces.IMailboxIMAPListener
Protocol implementation for an IMAP4rev1 server.
The server can be in any of four states:
Class Variable | IDENT | Undocumented |
Class Variable | timeOut | Undocumented |
Class Variable | POSTAUTH_TIMEOUT | Undocumented |
Instance Variable | startedTLS | Undocumented |
Instance Variable | canStartTLS | Undocumented |
Instance Variable | tags | Undocumented |
Class Variable | portal | Undocumented |
Instance Variable | account | Undocumented |
Instance Variable | mbox | Undocumented |
Instance Variable | challengers | Undocumented |
Instance Variable | state | Undocumented |
Instance Variable | parseState | Undocumented |
Method | __init__ | Undocumented |
Instance Variable | ctx | Undocumented |
Method | capabilities | Undocumented |
Method | connectionMade | Called when a connection is made. |
Method | connectionLost | Called when the connection is shut down. |
Method | timeoutConnection | Called when the connection times out. |
Method | rawDataReceived | Override this for when raw data is received. |
Instance Variable | blocked | Undocumented |
Method | lineReceived | Override this for when each line is received. |
Method | parse_command | Undocumented |
Method | parse_pending | Undocumented |
Method | dispatchCommand | Undocumented |
Method | lookupCommand | Undocumented |
Method | arg_finalastring | Parse an astring from line that represents a command's final argument. This special case exists to enable parsing empty string literals. |
Method | arg_astring | Parse an astring from the line, return (arg, rest), possibly via a deferred (to handle literals) |
Class Variable | atomre | Undocumented |
Method | arg_atom | Parse an atom from the line |
Method | arg_plist | Parse a (non-nested) parenthesised list from the line |
Method | arg_literal | Parse a literal from the line |
Method | arg_searchkeys | searchkeys |
Method | arg_seqset | sequence-set |
Method | arg_fetchatt | fetch-att |
Method | arg_flaglist | Flag part of store-att-flag |
Method | arg_line | Command line of UID command |
Method | opt_plist | Optional parenthesised list |
Method | opt_datetime | Optional date-time string |
Method | opt_charset | Optional charset of SEARCH command |
Method | sendServerGreeting | Undocumented |
Method | sendBadResponse | Undocumented |
Method | sendPositiveResponse | Undocumented |
Method | sendNegativeResponse | Undocumented |
Method | sendUntaggedResponse | Undocumented |
Method | sendContinuationRequest | Undocumented |
Method | listCapabilities | Undocumented |
Method | do_CAPABILITY | Undocumented |
Class Variable | unauth_CAPABILITY | Undocumented |
Method | do_LOGOUT | Undocumented |
Class Variable | unauth_LOGOUT | Undocumented |
Method | do_NOOP | Undocumented |
Class Variable | unauth_NOOP | Undocumented |
Method | do_AUTHENTICATE | Undocumented |
Class Variable | unauth_AUTHENTICATE | Undocumented |
Method | authenticate | Undocumented |
Method | do_STARTTLS | Undocumented |
Class Variable | unauth_STARTTLS | Undocumented |
Method | do_LOGIN | Undocumented |
Class Variable | unauth_LOGIN | Undocumented |
Method | authenticateLogin | Lookup the account associated with the given parameters |
Method | do_NAMESPACE | Undocumented |
Class Variable | auth_NAMESPACE | Undocumented |
Class Variable | auth_SELECT | Undocumented |
Class Variable | auth_EXAMINE | Undocumented |
Method | do_IDLE | Undocumented |
Instance Variable | parseTag | Undocumented |
Instance Variable | lastState | Undocumented |
Method | parse_idle | Undocumented |
Class Variable | select_IDLE | Undocumented |
Method | do_CREATE | Undocumented |
Class Variable | auth_CREATE | Undocumented |
Method | do_DELETE | Undocumented |
Class Variable | auth_DELETE | Undocumented |
Method | do_RENAME | Undocumented |
Class Variable | auth_RENAME | Undocumented |
Method | do_SUBSCRIBE | Undocumented |
Class Variable | auth_SUBSCRIBE | Undocumented |
Method | do_UNSUBSCRIBE | Undocumented |
Class Variable | auth_UNSUBSCRIBE | Undocumented |
Class Variable | auth_LIST | Undocumented |
Class Variable | auth_LSUB | Undocumented |
Method | do_STATUS | Undocumented |
Class Variable | auth_STATUS | Undocumented |
Method | do_APPEND | Undocumented |
Class Variable | auth_APPEND | Undocumented |
Method | do_CHECK | Undocumented |
Class Variable | select_CHECK | Undocumented |
Method | checkpoint | Called when the client issues a CHECK command. |
Method | do_CLOSE | Undocumented |
Class Variable | select_CLOSE | Undocumented |
Method | do_EXPUNGE | Undocumented |
Class Variable | select_EXPUNGE | Undocumented |
Method | do_SEARCH | Undocumented |
Class Variable | select_SEARCH | Undocumented |
Method | search_ALL | Returns True if the message matches the ALL search key (always). |
Method | search_ANSWERED | Returns True if the message has been answered. |
Method | search_BCC | Returns True if the message has a BCC address matching the query. |
Method | search_BEFORE | Undocumented |
Method | search_BODY | Undocumented |
Method | search_CC | Undocumented |
Method | search_DELETED | Undocumented |
Method | search_DRAFT | Undocumented |
Method | search_FLAGGED | Undocumented |
Method | search_FROM | Undocumented |
Method | search_HEADER | Undocumented |
Method | search_KEYWORD | Undocumented |
Method | search_LARGER | Undocumented |
Method | search_NEW | Undocumented |
Method | search_NOT | Returns True if the message does not match the query. |
Method | search_OLD | Undocumented |
Method | search_ON | Undocumented |
Method | search_OR | Returns True if the message matches any of the first two query items. |
Method | search_RECENT | Undocumented |
Method | search_SEEN | Undocumented |
Method | search_SENTBEFORE | Returns True if the message date is earlier than the query date. |
Method | search_SENTON | Returns True if the message date is the same as the query date. |
Method | search_SENTSINCE | Returns True if the message date is later than the query date. |
Method | search_SINCE | Undocumented |
Method | search_SMALLER | Undocumented |
Method | search_SUBJECT | Undocumented |
Method | search_TEXT | Undocumented |
Method | search_TO | Undocumented |
Method | search_UID | Returns True if the message UID is in the range defined by the search query. |
Method | search_UNANSWERED | Undocumented |
Method | search_UNDELETED | Undocumented |
Method | search_UNDRAFT | Undocumented |
Method | search_UNFLAGGED | Undocumented |
Method | search_UNKEYWORD | Undocumented |
Method | search_UNSEEN | Undocumented |
Method | do_FETCH | Undocumented |
Class Variable | select_FETCH | Undocumented |
Method | spew_envelope | Undocumented |
Method | spew_flags | Undocumented |
Method | spew_internaldate | Undocumented |
Method | spew_rfc822header | Undocumented |
Method | spew_rfc822text | Undocumented |
Method | spew_rfc822size | Undocumented |
Method | spew_rfc822 | Undocumented |
Method | spew_uid | Undocumented |
Method | spew_bodystructure | Undocumented |
Method | spew_body | Undocumented |
Method | spewMessage | Undocumented |
Method | do_STORE | Undocumented |
Class Variable | select_STORE | Undocumented |
Method | do_COPY | Undocumented |
Class Variable | select_COPY | Undocumented |
Method | do_UID | Undocumented |
Class Variable | select_UID | Undocumented |
Method | modeChanged | Indicates that the write status of a mailbox has changed. |
Method | flagsChanged | Indicates that the flags of one or more messages have changed. |
Method | newMessages | Indicates that the number of messages in a mailbox has changed. |
Instance Variable | _onLogout | Undocumented |
Instance Variable | _pendingLiteral | Undocumented |
Class Variable | _literalStringLimit | Undocumented |
Class Variable | _requiresLastMessageInfo | Undocumented |
Instance Variable | _scheduler | Undocumented |
Instance Variable | _queuedAsync | Undocumented |
Method | _unblock | Undocumented |
Method | __doCommand | Undocumented |
Method | __cbDispatch | Undocumented |
Method | __ebDispatch | Undocumented |
Method | _stringLiteral | Undocumented |
Method | _fileLiteral | Undocumented |
Method | _respond | Undocumented |
Method | _setupChallenge | Undocumented |
Method | __cbAuthChunk | Undocumented |
Method | __cbAuthResp | Undocumented |
Method | __ebAuthResp | Undocumented |
Method | __ebAuthChunk | Undocumented |
Method | __cbLogin | Undocumented |
Method | __ebLogin | Undocumented |
Method | _selectWork | Undocumented |
Method | _ebSelectWork | Undocumented |
Method | _cbSelectWork | Undocumented |
Method | _listWork | Undocumented |
Method | _cbListWork | Undocumented |
Method | _ebListWork | Undocumented |
Method | _cbStatusGotMailbox | Undocumented |
Method | _ebStatusGotMailbox | Undocumented |
Method | __cbStatus | Undocumented |
Method | __ebStatus | Undocumented |
Method | _cbAppendGotMailbox | Undocumented |
Method | _ebAppendGotMailbox | Undocumented |
Method | __cbAppend | Undocumented |
Method | __ebAppend | Undocumented |
Method | __cbCheck | Undocumented |
Method | __ebCheck | Undocumented |
Method | __cbClose | Undocumented |
Method | __ebClose | Undocumented |
Method | __cbExpunge | Undocumented |
Method | __ebExpunge | Undocumented |
Method | __cbSearch | Undocumented |
Method | __cbManualSearch | Apply the search filter to a set of messages. Send the response to the client. |
Method | _searchFilter | Pop search terms from the beginning of query until there are none left and apply them to the given message. |
Method | _singleSearchStep | Pop one search term from the beginning of query (possibly more than one element) and return whether it matches the given message. |
Method | __ebSearch | Undocumented |
Instance Variable | _oldTimeout | Undocumented |
Method | __cbFetch | Undocumented |
Method | __ebSpewMessage | Undocumented |
Method | __ebFetch | Undocumented |
Method | __cbStore | Undocumented |
Method | __ebStore | Undocumented |
Method | _cbCopySelectedMailbox | Undocumented |
Method | _ebCopySelectedMailbox | Undocumented |
Method | __cbCopy | Undocumented |
Method | __cbCopied | Undocumented |
Method | __ebCopy | Undocumented |
Inherited from LineReceiver:
Class Variable | delimiter | The line-ending delimiter to use. By default this is b'\r\n' . |
Class Variable | MAX_LENGTH | The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped). Default is 16384. |
Instance Variable | line_mode | Undocumented |
Method | clearLineBuffer | Clear buffered data. |
Method | dataReceived | Protocol.dataReceived. Translates bytes into lines, and calls lineReceived (or rawDataReceived, depending on mode.) |
Method | setLineMode | Sets the line-mode of this receiver. |
Method | setRawMode | Sets the raw mode of this receiver. Further data received will be sent to rawDataReceived rather than lineReceived. |
Method | sendLine | Sends a line to the other end of the connection. |
Method | lineLengthExceeded | Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way. |
Instance Variable | _buffer | Undocumented |
Instance Variable | _busyReceiving | Undocumented |
Inherited from Protocol (via LineReceiver):
Class Variable | factory | Undocumented |
Method | logPrefix | Return a prefix matching the class name, to identify log messages related to this protocol instance. |
Inherited from BaseProtocol (via LineReceiver, Protocol):
Instance Variable | connected | Undocumented |
Instance Variable | transport | Undocumented |
Method | makeConnection | Make a connection to a transport and a server. |
Inherited from _PauseableMixin (via LineReceiver):
Instance Variable | paused | Undocumented |
Method | pauseProducing | Undocumented |
Method | resumeProducing | Undocumented |
Method | stopProducing | Undocumented |
Inherited from TimeoutMixin:
Method | callLater | Wrapper around reactor.callLater for test purpose. |
Method | resetTimeout | Reset the timeout count down. |
Method | setTimeout | Change the timeout period |
Instance Variable | __timeoutCall | Undocumented |
Method | __timedOut | Undocumented |
Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
Called when the connection is shut down.
Clear any circular references here, and any external references to this Protocol. The connection has been closed.
Parameters | reason | Undocumented (type: twisted.python.failure.Failure ) |
Called when the connection times out.
Override to define behavior other than dropping the connection.
Override this for when each line is received.
Parameters | line | The line which was received with the delimiter removed. (type: bytes ) |
Parse an astring from line that represents a command's final argument. This special case exists to enable parsing empty string literals.
Parameters | line | A line that contains a string literal. (type: bytes ) |
Returns | A 2-tuple containing the parsed argument and any trailing data, or a Deferred that fires with that 2-tuple (type: tuple of (bytes , bytes ) or a Deferred ) | |
See Also | https://twistedmatrix.com/trac/ticket/9207 |
Parse an astring from the line, return (arg, rest), possibly via a deferred (to handle literals)
Parameters | line | A line that contains a string literal. (type: bytes ) |
final | Is this the final argument? @type final bool | |
Returns | A 2-tuple containing the parsed argument and any trailing data, or a Deferred that fires with that 2-tuple (type: tuple of (bytes , bytes ) or a Deferred ) |
Lookup the account associated with the given parameters
Override this method to define the desired authentication behavior.
The default behavior is to defer authentication to self.portal
if it is not None, or to deny the login otherwise.
Parameters | user | The username to lookup (type: str ) |
passwd | The password to login with (type: str ) |
Called when the client issues a CHECK command.
This should perform any checkpoint operations required by the server. It may be a long running operation, but may not block. If it returns a deferred, the client will only be informed of success (or failure) when the deferred's callback (or errback) is invoked.
Apply the search filter to a set of messages. Send the response to the client.
Parameters | result | A list two tuples of messages with their sequence ids, sorted by the ids in descending order. (type: list of tuple of (int , provider of imap4.IMessage )) |
tag | A command tag. (type: str ) | |
mbox | The searched mailbox. (type: Provider of imap4.IMailbox ) | |
query | A list representing the parsed form of the search query. (type: list ) | |
uid | A flag indicating whether the search is over message sequence numbers or UIDs. | |
searchResults | The search results so far or None if no results yet. (type: list ) |
Pop search terms from the beginning of query
until there are none left and apply them to the given message.
Parameters | query | A list representing the parsed form of the search query. |
id | The sequence number of the message being checked. | |
msg | The message being checked. | |
lastSequenceId | The highest sequence number of any message in the mailbox being searched. (type: int ) | |
lastMessageId | The highest UID of any message in the mailbox being searched. (type: int ) | |
Returns | Boolean indicating whether all of the query terms match the message. |
Pop one search term from the beginning of query
(possibly more than one element) and return whether it matches the given message.
Parameters | query | A list representing the parsed form of the search query. |
msgId | The sequence number of the message being checked. | |
msg | The message being checked. | |
lastSequenceId | The highest sequence number of any message in the mailbox being searched. | |
lastMessageId | The highest UID of any message in the mailbox being searched. | |
Returns | Boolean indicating whether the query term matched the message. |
Returns True
if the message matches the ALL search key (always).
Parameters | query | A list representing the parsed query string. (type: A list of str ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | Undocumented (type: Provider of imap4.IMessage ) |
Returns True
if the message has been answered.
Parameters | query | A list representing the parsed query string. (type: A list of str ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | Undocumented (type: Provider of imap4.IMessage ) |
Returns True
if the message has a BCC address matching the query.
Parameters | query | A list whose first element is a BCC str (type: A list of str ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | Undocumented (type: Provider of imap4.IMessage ) |
Returns True
if the message does not match the query.
Parameters | query | A list representing the parsed form of the search query. (type: A list of str ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | The message being checked. (type: Provider of imap4.IMessage ) | |
lastIDs | A tuple of (last sequence id, last message id). The last sequence id is an int containing the highest sequence number of a message in the mailbox. The last message id is an int containing the highest UID of a message in the mailbox. (type: tuple ) |
Returns True
if the message matches any of the first two query items.
Parameters | query | A list representing the parsed form of the search query. (type: A list of str ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | The message being checked. (type: Provider of imap4.IMessage ) | |
lastIDs | A tuple of (last sequence id, last message id). The last sequence id is an int containing the highest sequence number of a message in the mailbox. The last message id is an int containing the highest UID of a message in the mailbox. (type: tuple ) |
Returns True
if the message date is earlier than the query date.
Parameters | query | A list whose first element starts with a stringified date that is a fragment of an imap4.Query() . The date must be in the format 'DD-Mon-YYYY', for example '03-March-2003' or '03-Mar-2003'. (type: A list of str ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | Undocumented (type: Provider of imap4.IMessage ) |
Returns True
if the message date is the same as the query date.
Parameters | query | A list whose first element starts with a stringified date that is a fragment of an imap4.Query() . The date must be in the format 'DD-Mon-YYYY', for example '03-March-2003' or '03-Mar-2003'. (type: A list of str ) |
id | Undocumented | |
msg | Undocumented (type: Provider of imap4.IMessage ) |
Returns True
if the message date is later than the query date.
Parameters | query | A list whose first element starts with a stringified date that is a fragment of an imap4.Query() . The date must be in the format 'DD-Mon-YYYY', for example '03-March-2003' or '03-Mar-2003'. (type: A list of str ) |
id | Undocumented | |
msg | Undocumented (type: Provider of imap4.IMessage ) |
Returns True
if the message UID is in the range defined by the search query.
Parameters | query | A list representing the parsed form of the search query. Its first element should be a str that can be interpreted as a sequence range, for example '2:4,5:*'. (type: A list of bytes ) |
id | The sequence number of the message being checked. (type: int ) | |
msg | The message being checked. (type: Provider of imap4.IMessage ) | |
lastIDs | A tuple of (last sequence id, last message id). The last sequence id is an int containing the highest sequence number of a message in the mailbox. The last message id is an int containing the highest UID of a message in the mailbox. (type: tuple ) |
Indicates that the write status of a mailbox has changed.
Parameters | writeable | A true value if write is now allowed, false otherwise. (type: bool ) |
Indicates that the flags of one or more messages have changed.
Parameters | newFlags | A mapping of message identifiers to tuples of flags now set on that message. (type: dict ) |
Indicates that the number of messages in a mailbox has changed.
Parameters | exists | The total number of messages now in this mailbox. If the total number of messages has not changed, this should be None . (type: int or None ) |
recent | The number of messages now flagged \Recent . If the number of recent messages has not changed, this should be None . (type: int ) |