An abstract representation of a mailbox on an IMAP Server. This class
implements the mailbox.Mailbox interface, insofar possible. Methods for
changing a message in-place are not available for IMAP; the 'update' and
'__setitem__' methods will raise a NotSupportedError. By default deleting
messages (discard/remove) just adds the \Deleted flag to the message.
Optionally, you can define a trash folder for any ImapMailbox. If set,
"deleted" messages will be moved to the trash folder. Note that
you must set the trash folder to '[Gmail]/Trash' if you are using Gmail,
as the Gmail IMAP server has a different interpretation of what deletion
means.
name name of the mailbox (readonly, see below) server
ImapServer object (readonly, see below) trash Trash folder
readonly True if mailbox is readonly, false otherwise
The 'trash' attribute may a string, another instance of ImapMailbox,
or an instance of mailbox.Mailbox. If not set, it is None.
If the 'readonly' attribute is set, all subsequent calls that would
change the mailbox will raise a ReadOnlyError. Note that setting the
readonly attribute does not prevent you from making changes through the
methods of the server attribute.
|
__init__(self,
path,
factory=<class ProcImap.ImapMessage.ImapMessage at 0x11206c0>,
readonly=False,
create=True)
Initialize an ImapMailbox path is a tuple with two elements,
consisting of 1) an instance of ImapServer in any state 2) the name
of a mailbox on the server as a string If the mailbox does not exist,
it is created unless create is set to False, in which case
NoSuchMailboxError is raised. |
source code
|
|
|
reconnect(self)
Renew the connection to the mailbox |
source code
|
|
|
switch(self,
name,
readonly=False,
create=False)
Switch to a different Mailbox on the same server |
source code
|
|
|
search(self,
criteria=' ALL ' ,
charset=None)
Return a list of all the UIDs in the mailbox (as integers)
that match the search criteria. |
source code
|
|
|
get_unseen_uids(self)
Get a list of all the unseen UIDs in the mailbox Equivalent to
search(None, "UNSEEN UNDELETED") |
source code
|
|
|
|
|
|
|
|
|
|
|
get(self,
uid,
default=None)
Return an ImapMessage object created from the message with UID. |
source code
|
|
|
get_string(self,
uid)
Return a RFC822 string representation of the message corresponding to
key, or raise a KeyError exception if no such message exists. |
source code
|
|
|
get_file(self,
uid)
Return a cStringIO.StringIO of the message corresponding to key, or
raise a KeyError exception if no such message exists. |
source code
|
|
|
has_key(self,
uid)
Return True if key corresponds to a message, False otherwise. |
source code
|
|
|
|
|
|
|
|
|
pop(self,
uid,
default=None)
Return a representation of the message corresponding to key, delete
and expunge the message. |
source code
|
|
|
popitem(self)
Return an arbitrary (key, message) pair, where key is a key and
message is a message representation, delete and expunge the
corresponding message. |
source code
|
|
|
update(self,
arg=None)
Parameter arg should be a key-to-message mapping or an iterable of
(key, message) pairs. |
source code
|
|
|
|
|
|
|
|
|
get_header(self,
uid)
Return an ImapMessage object containing only the Header of the
message with UID. |
source code
|
|
|
get_fields(self,
uid,
fields)
Return an mailbox.Message object containing only the requested header
fields of the message with UID. |
source code
|
|
|
get_size(self,
uid)
Get the number of bytes contained in the message with UID |
source code
|
|
|
get_imapflags(self,
uid)
Return a list of imap flags for the message with UID Raise exception
if there if there is no message with that UID. |
source code
|
|
|
get_internaldate(self,
uid)
Return a time tuple representing the internal date for the message
with UID Raise exception if there if there is no message with that
UID. |
source code
|
|
|
__eq__(self,
other)
Equality test: mailboxes are equal if they are equal in server and
name |
source code
|
|
|
__ne__(self,
other)
Inequality test: mailboxes are unequal if they are not equal |
source code
|
|
|
copy(self,
uid,
targetmailbox,
exact=False)
Copy the message with UID to the targetmailbox and try to return the
key that was assigned to the copied message in the targetmailbox. |
source code
|
|
|
move(self,
uid,
targetmailbox,
exact=False)
Copy the message with UID to the targetmailbox, delete it in the
original mailbox, and try to return the key that was assigned to the
copied message in the targetmailbox. |
source code
|
|
|
discard(self,
uid,
exact=False)
If trash folder is defined, move the message with UID to trash and
try to return the key assigned to the message in the trash; else,
just add the \Deleted flag to the message with UID and return None. |
source code
|
|
|
|
|
|
|
|
|
iterkeys(self)
Return an iterator over all UIDs This is an iterator over the list of
UIDs at the time iterkeys() is a called. |
source code
|
|
|
|
|
|
|
|
|
values(self)
Return a list of all messages The messages are represented as
instances of ImapMessage unless a custom message factory was
specified when the Mailbox instance was initialized. |
source code
|
|
|
iteritems(self)
Return an iterator over (uid, message) pairs, where uid is a key and
message is a message representation. |
source code
|
|
|
items(self)
Return a list (uid, message) pairs, where uid is a key and message is
a message representation. |
source code
|
|
|
|
|
add_imapflag(self,
uid,
*flags)
Add imap flag to message with UID. |
source code
|
|
|
remove_imapflag(self,
uid,
*flags)
Remove imap flags from message with UID |
source code
|
|
|
set_imapflags(self,
uid,
flags)
Set imap flags for message with UID flags must be an iterable of
flags, or a string. |
source code
|
|
|
|
|
expunge(self)
Expunge the mailbox (delete all messages marked for deletion) |
source code
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
Inherited from mailbox.Mailbox (private):
_dump_message
|