Go to the latest version of this document.

# ``twisted`.`mail`.`interfaces`.`IMailboxIMAP``

interface documentation

`class IMailboxIMAP(IMailboxIMAPInfo): (source)`

View In Hierarchy

Undocumented

Method | `addListener` | Add a mailbox change listener
Method | `addMessage` | Add the given message to this mailbox.
Method | `destroy` | Called before this mailbox is deleted, permanently.
Method | `expunge` | Remove all messages flagged \Deleted.
Method | `fetch` | Retrieve one or more messages.
Method | `getMessageCount` | Return the number of messages in this mailbox.
Method | `getRecentCount` | Return the number of messages with the 'Recent' flag.
Method | `getUID` | Return the UID of a message in the mailbox
Method | `getUIDNext` | Return the likely UID for the next message added to this mailbox.
Method | `getUIDValidity` | Return the unique validity identifier for this mailbox.
Method | `getUnseenCount` | Return the number of messages with the 'Unseen' flag.
Method | `isWriteable` | Get the read/write status of the mailbox.
Method | `removeListener` | Remove a mailbox change listener
Method | `requestStatus` | Return status information about this mailbox.
Method | `store` | Set the flags of one or more messages.

Inherited from `IMailboxIMAPInfo`:

Method | `getFlags` | Return the flags defined in this mailbox
Method | `getHierarchicalDelimiter` | Get the character which delimits namespaces for in this mailbox.

def addListener(listener): (source)

Add a mailbox change listener

Parameters
listener:Any object which implements `IMailboxIMAPListener` | An object to add to the set of those which will be notified when the contents of this mailbox change.

def addMessage(message, flags, date): (source)

Add the given message to this mailbox.

Parameters
message:A file-like object | The RFC822 formatted message
flags:Any iterable of `bytes` | The flags to associate with this message
date:`bytes` | If specified, the date to associate with this message.

Returns
`Deferred` | A deferred whose callback is invoked with the message id if the message is added successfully and whose errback is invoked otherwise.

Raises
`ReadOnlyMailbox` | Raised if this Mailbox is not open for read-write.

def destroy(): (source)

Called before this mailbox is deleted, permanently.

If necessary, all resources held by this mailbox should be cleaned up here. This function _must_ set the \Noselect flag on this mailbox.

def expunge(): (source)

Remove all messages flagged \Deleted.

Returns
`list` or `Deferred` | The list of message sequence numbers which were deleted, or a `Deferred` whose callback will be invoked with such a list.

Raises
`ReadOnlyMailbox` | Raised if this Mailbox is not open for read-write.

def fetch(messages, uid): (source)

Retrieve one or more messages.

Parameters
messages:`MessageSet` | The identifiers of messages to retrieve information about
uid:`bool` | If true, the IDs specified in the query are UIDs; otherwise they are message sequence IDs.

Returns
Any iterable of two-tuples of message sequence numbers and implementors of `IMessageIMAP`. | Undocumented

def getMessageCount(): (source)

Return the number of messages in this mailbox.

Returns
`int` | Undocumented

def getRecentCount(): (source)

Return the number of messages with the 'Recent' flag.

Returns
`int` | Undocumented

def getUID(message): (source)

Return the UID of a message in the mailbox

Parameters
message:`int` | The message sequence number

Returns
`int` | The UID of the message.

def getUIDNext(): (source)

Return the likely UID for the next message added to this mailbox.

Returns
`int` | Undocumented

def getUIDValidity(): (source)

Return the unique validity identifier for this mailbox.

Returns
`int` | Undocumented

def getUnseenCount(): (source)

Return the number of messages with the 'Unseen' flag.

Returns
`int` | Undocumented

def isWriteable(): (source)

Get the read/write status of the mailbox.

Returns
`int` | A true value if write permission is allowed, a false value otherwise.

def removeListener(listener): (source)

Remove a mailbox change listener

Parameters
listener:Any object previously added to and not removed from this mailbox as a listener. | The object to remove from the set of listeners.

Raises
`ValueError` | Raised when the given object is not a listener for this mailbox.

def requestStatus(names): (source)

Return status information about this mailbox.

Mailboxes which do not intend to do any special processing to generate the return value, `statusRequestHelper` can be used to build the dictionary by calling the other interface methods which return the data for each name.

Parameters
names:Any iterable | The status names to return information regarding. The possible values for each name are: MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN.

Returns
`dict` or `Deferred` | A dictionary containing status information about the requested names is returned. If the process of looking this information up would be costly, a deferred whose callback will eventually be passed this dictionary is returned instead.

def store(messages, flags, mode, uid): (source)

Set the flags of one or more messages.

Parameters
messages:A MessageSet object with the list of messages requested | The identifiers of the messages to set the flags of.
flags:sequence of `str` | The flags to set, unset, or add.
mode:-1, 0, or 1 | If mode is -1, these flags should be removed from the specified messages. If mode is 1, these flags should be added to the specified messages. If mode is 0, all existing flags should be cleared and these flags should be added.
uid:`bool` | If true, the IDs specified in the query are UIDs; otherwise they are message sequence IDs.

Returns
`dict` or `Deferred` | A `dict` mapping message sequence numbers to sequences of `str` representing the flags set on the message after this operation has been performed, or a `Deferred` whose callback will be invoked with such a `dict`.

Raises
`ReadOnlyMailbox` | Raised if this mailbox is not open for read-write.