Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/imh-pyth.../lib/python2....
File: imaplib.py
"""IMAP4 client.
[0] Fix | Delete
[1] Fix | Delete
Based on RFC 2060.
[2] Fix | Delete
[3] Fix | Delete
Public class: IMAP4
[4] Fix | Delete
Public variable: Debug
[5] Fix | Delete
Public functions: Internaldate2tuple
[6] Fix | Delete
Int2AP
[7] Fix | Delete
ParseFlags
[8] Fix | Delete
Time2Internaldate
[9] Fix | Delete
"""
[10] Fix | Delete
[11] Fix | Delete
# Author: Piers Lauder <piers@cs.su.oz.au> December 1997.
[12] Fix | Delete
#
[13] Fix | Delete
# Authentication code contributed by Donn Cave <donn@u.washington.edu> June 1998.
[14] Fix | Delete
# String method conversion by ESR, February 2001.
[15] Fix | Delete
# GET/SETACL contributed by Anthony Baxter <anthony@interlink.com.au> April 2001.
[16] Fix | Delete
# IMAP4_SSL contributed by Tino Lange <Tino.Lange@isg.de> March 2002.
[17] Fix | Delete
# GET/SETQUOTA contributed by Andreas Zeidler <az@kreativkombinat.de> June 2002.
[18] Fix | Delete
# PROXYAUTH contributed by Rick Holbert <holbert.13@osu.edu> November 2002.
[19] Fix | Delete
# GET/SETANNOTATION contributed by Tomas Lindroos <skitta@abo.fi> June 2005.
[20] Fix | Delete
[21] Fix | Delete
__version__ = "2.58"
[22] Fix | Delete
[23] Fix | Delete
import binascii, errno, random, re, socket, subprocess, sys, time
[24] Fix | Delete
[25] Fix | Delete
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
[26] Fix | Delete
"Int2AP", "ParseFlags", "Time2Internaldate"]
[27] Fix | Delete
[28] Fix | Delete
# Globals
[29] Fix | Delete
[30] Fix | Delete
CRLF = '\r\n'
[31] Fix | Delete
Debug = 0
[32] Fix | Delete
IMAP4_PORT = 143
[33] Fix | Delete
IMAP4_SSL_PORT = 993
[34] Fix | Delete
AllowedVersions = ('IMAP4REV1', 'IMAP4') # Most recent first
[35] Fix | Delete
[36] Fix | Delete
# Maximal line length when calling readline(). This is to prevent
[37] Fix | Delete
# reading arbitrary length lines. RFC 3501 and 2060 (IMAP 4rev1)
[38] Fix | Delete
# don't specify a line length. RFC 2683 suggests limiting client
[39] Fix | Delete
# command lines to 1000 octets and that servers should be prepared
[40] Fix | Delete
# to accept command lines up to 8000 octets, so we used to use 10K here.
[41] Fix | Delete
# In the modern world (eg: gmail) the response to, for example, a
[42] Fix | Delete
# search command can be quite large, so we now use 1M.
[43] Fix | Delete
_MAXLINE = 1000000
[44] Fix | Delete
[45] Fix | Delete
[46] Fix | Delete
# Commands
[47] Fix | Delete
[48] Fix | Delete
Commands = {
[49] Fix | Delete
# name valid states
[50] Fix | Delete
'APPEND': ('AUTH', 'SELECTED'),
[51] Fix | Delete
'AUTHENTICATE': ('NONAUTH',),
[52] Fix | Delete
'CAPABILITY': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'),
[53] Fix | Delete
'CHECK': ('SELECTED',),
[54] Fix | Delete
'CLOSE': ('SELECTED',),
[55] Fix | Delete
'COPY': ('SELECTED',),
[56] Fix | Delete
'CREATE': ('AUTH', 'SELECTED'),
[57] Fix | Delete
'DELETE': ('AUTH', 'SELECTED'),
[58] Fix | Delete
'DELETEACL': ('AUTH', 'SELECTED'),
[59] Fix | Delete
'EXAMINE': ('AUTH', 'SELECTED'),
[60] Fix | Delete
'EXPUNGE': ('SELECTED',),
[61] Fix | Delete
'FETCH': ('SELECTED',),
[62] Fix | Delete
'GETACL': ('AUTH', 'SELECTED'),
[63] Fix | Delete
'GETANNOTATION':('AUTH', 'SELECTED'),
[64] Fix | Delete
'GETQUOTA': ('AUTH', 'SELECTED'),
[65] Fix | Delete
'GETQUOTAROOT': ('AUTH', 'SELECTED'),
[66] Fix | Delete
'MYRIGHTS': ('AUTH', 'SELECTED'),
[67] Fix | Delete
'LIST': ('AUTH', 'SELECTED'),
[68] Fix | Delete
'LOGIN': ('NONAUTH',),
[69] Fix | Delete
'LOGOUT': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'),
[70] Fix | Delete
'LSUB': ('AUTH', 'SELECTED'),
[71] Fix | Delete
'NAMESPACE': ('AUTH', 'SELECTED'),
[72] Fix | Delete
'NOOP': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'),
[73] Fix | Delete
'PARTIAL': ('SELECTED',), # NB: obsolete
[74] Fix | Delete
'PROXYAUTH': ('AUTH',),
[75] Fix | Delete
'RENAME': ('AUTH', 'SELECTED'),
[76] Fix | Delete
'SEARCH': ('SELECTED',),
[77] Fix | Delete
'SELECT': ('AUTH', 'SELECTED'),
[78] Fix | Delete
'SETACL': ('AUTH', 'SELECTED'),
[79] Fix | Delete
'SETANNOTATION':('AUTH', 'SELECTED'),
[80] Fix | Delete
'SETQUOTA': ('AUTH', 'SELECTED'),
[81] Fix | Delete
'SORT': ('SELECTED',),
[82] Fix | Delete
'STATUS': ('AUTH', 'SELECTED'),
[83] Fix | Delete
'STORE': ('SELECTED',),
[84] Fix | Delete
'SUBSCRIBE': ('AUTH', 'SELECTED'),
[85] Fix | Delete
'THREAD': ('SELECTED',),
[86] Fix | Delete
'UID': ('SELECTED',),
[87] Fix | Delete
'UNSUBSCRIBE': ('AUTH', 'SELECTED'),
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
# Patterns to match server responses
[91] Fix | Delete
[92] Fix | Delete
Continuation = re.compile(r'\+( (?P<data>.*))?')
[93] Fix | Delete
Flags = re.compile(r'.*FLAGS \((?P<flags>[^\)]*)\)')
[94] Fix | Delete
InternalDate = re.compile(r'.*INTERNALDATE "'
[95] Fix | Delete
r'(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9])'
[96] Fix | Delete
r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
[97] Fix | Delete
r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
[98] Fix | Delete
r'"')
[99] Fix | Delete
Literal = re.compile(r'.*{(?P<size>\d+)}$')
[100] Fix | Delete
MapCRLF = re.compile(r'\r\n|\r|\n')
[101] Fix | Delete
Response_code = re.compile(r'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
[102] Fix | Delete
Untagged_response = re.compile(r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
[103] Fix | Delete
Untagged_status = re.compile(r'\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?')
[104] Fix | Delete
[105] Fix | Delete
[106] Fix | Delete
[107] Fix | Delete
class IMAP4:
[108] Fix | Delete
[109] Fix | Delete
"""IMAP4 client class.
[110] Fix | Delete
[111] Fix | Delete
Instantiate with: IMAP4([host[, port]])
[112] Fix | Delete
[113] Fix | Delete
host - host's name (default: localhost);
[114] Fix | Delete
port - port number (default: standard IMAP4 port).
[115] Fix | Delete
[116] Fix | Delete
All IMAP4rev1 commands are supported by methods of the same
[117] Fix | Delete
name (in lower-case).
[118] Fix | Delete
[119] Fix | Delete
All arguments to commands are converted to strings, except for
[120] Fix | Delete
AUTHENTICATE, and the last argument to APPEND which is passed as
[121] Fix | Delete
an IMAP4 literal. If necessary (the string contains any
[122] Fix | Delete
non-printing characters or white-space and isn't enclosed with
[123] Fix | Delete
either parentheses or double quotes) each string is quoted.
[124] Fix | Delete
However, the 'password' argument to the LOGIN command is always
[125] Fix | Delete
quoted. If you want to avoid having an argument string quoted
[126] Fix | Delete
(eg: the 'flags' argument to STORE) then enclose the string in
[127] Fix | Delete
parentheses (eg: "(\Deleted)").
[128] Fix | Delete
[129] Fix | Delete
Each command returns a tuple: (type, [data, ...]) where 'type'
[130] Fix | Delete
is usually 'OK' or 'NO', and 'data' is either the text from the
[131] Fix | Delete
tagged response, or untagged results from command. Each 'data'
[132] Fix | Delete
is either a string, or a tuple. If a tuple, then the first part
[133] Fix | Delete
is the header of the response, and the second part contains
[134] Fix | Delete
the data (ie: 'literal' value).
[135] Fix | Delete
[136] Fix | Delete
Errors raise the exception class <instance>.error("<reason>").
[137] Fix | Delete
IMAP4 server errors raise <instance>.abort("<reason>"),
[138] Fix | Delete
which is a sub-class of 'error'. Mailbox status changes
[139] Fix | Delete
from READ-WRITE to READ-ONLY raise the exception class
[140] Fix | Delete
<instance>.readonly("<reason>"), which is a sub-class of 'abort'.
[141] Fix | Delete
[142] Fix | Delete
"error" exceptions imply a program error.
[143] Fix | Delete
"abort" exceptions imply the connection should be reset, and
[144] Fix | Delete
the command re-tried.
[145] Fix | Delete
"readonly" exceptions imply the command should be re-tried.
[146] Fix | Delete
[147] Fix | Delete
Note: to use this module, you must read the RFCs pertaining to the
[148] Fix | Delete
IMAP4 protocol, as the semantics of the arguments to each IMAP4
[149] Fix | Delete
command are left to the invoker, not to mention the results. Also,
[150] Fix | Delete
most IMAP servers implement a sub-set of the commands available here.
[151] Fix | Delete
"""
[152] Fix | Delete
[153] Fix | Delete
class error(Exception): pass # Logical errors - debug required
[154] Fix | Delete
class abort(error): pass # Service errors - close and retry
[155] Fix | Delete
class readonly(abort): pass # Mailbox status changed to READ-ONLY
[156] Fix | Delete
[157] Fix | Delete
mustquote = re.compile(r"[^\w!#$%&'*+,.:;<=>?^`|~-]")
[158] Fix | Delete
[159] Fix | Delete
def __init__(self, host = '', port = IMAP4_PORT):
[160] Fix | Delete
self.debug = Debug
[161] Fix | Delete
self.state = 'LOGOUT'
[162] Fix | Delete
self.literal = None # A literal argument to a command
[163] Fix | Delete
self.tagged_commands = {} # Tagged commands awaiting response
[164] Fix | Delete
self.untagged_responses = {} # {typ: [data, ...], ...}
[165] Fix | Delete
self.continuation_response = '' # Last continuation response
[166] Fix | Delete
self.is_readonly = False # READ-ONLY desired state
[167] Fix | Delete
self.tagnum = 0
[168] Fix | Delete
[169] Fix | Delete
# Open socket to server.
[170] Fix | Delete
[171] Fix | Delete
self.open(host, port)
[172] Fix | Delete
[173] Fix | Delete
# Create unique tag for this session,
[174] Fix | Delete
# and compile tagged response matcher.
[175] Fix | Delete
[176] Fix | Delete
self.tagpre = Int2AP(random.randint(4096, 65535))
[177] Fix | Delete
self.tagre = re.compile(r'(?P<tag>'
[178] Fix | Delete
+ self.tagpre
[179] Fix | Delete
+ r'\d+) (?P<type>[A-Z]+) (?P<data>.*)')
[180] Fix | Delete
[181] Fix | Delete
# Get server welcome message,
[182] Fix | Delete
# request and store CAPABILITY response.
[183] Fix | Delete
[184] Fix | Delete
if __debug__:
[185] Fix | Delete
self._cmd_log_len = 10
[186] Fix | Delete
self._cmd_log_idx = 0
[187] Fix | Delete
self._cmd_log = {} # Last `_cmd_log_len' interactions
[188] Fix | Delete
if self.debug >= 1:
[189] Fix | Delete
self._mesg('imaplib version %s' % __version__)
[190] Fix | Delete
self._mesg('new IMAP4 connection, tag=%s' % self.tagpre)
[191] Fix | Delete
[192] Fix | Delete
self.welcome = self._get_response()
[193] Fix | Delete
if 'PREAUTH' in self.untagged_responses:
[194] Fix | Delete
self.state = 'AUTH'
[195] Fix | Delete
elif 'OK' in self.untagged_responses:
[196] Fix | Delete
self.state = 'NONAUTH'
[197] Fix | Delete
else:
[198] Fix | Delete
raise self.error(self.welcome)
[199] Fix | Delete
[200] Fix | Delete
typ, dat = self.capability()
[201] Fix | Delete
if dat == [None]:
[202] Fix | Delete
raise self.error('no CAPABILITY response from server')
[203] Fix | Delete
self.capabilities = tuple(dat[-1].upper().split())
[204] Fix | Delete
[205] Fix | Delete
if __debug__:
[206] Fix | Delete
if self.debug >= 3:
[207] Fix | Delete
self._mesg('CAPABILITIES: %r' % (self.capabilities,))
[208] Fix | Delete
[209] Fix | Delete
for version in AllowedVersions:
[210] Fix | Delete
if not version in self.capabilities:
[211] Fix | Delete
continue
[212] Fix | Delete
self.PROTOCOL_VERSION = version
[213] Fix | Delete
return
[214] Fix | Delete
[215] Fix | Delete
raise self.error('server not IMAP4 compliant')
[216] Fix | Delete
[217] Fix | Delete
[218] Fix | Delete
def __getattr__(self, attr):
[219] Fix | Delete
# Allow UPPERCASE variants of IMAP4 command methods.
[220] Fix | Delete
if attr in Commands:
[221] Fix | Delete
return getattr(self, attr.lower())
[222] Fix | Delete
raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
[223] Fix | Delete
[224] Fix | Delete
[225] Fix | Delete
[226] Fix | Delete
# Overridable methods
[227] Fix | Delete
[228] Fix | Delete
[229] Fix | Delete
def open(self, host = '', port = IMAP4_PORT):
[230] Fix | Delete
"""Setup connection to remote server on "host:port"
[231] Fix | Delete
(default: localhost:standard IMAP4 port).
[232] Fix | Delete
This connection will be used by the routines:
[233] Fix | Delete
read, readline, send, shutdown.
[234] Fix | Delete
"""
[235] Fix | Delete
self.host = host
[236] Fix | Delete
self.port = port
[237] Fix | Delete
self.sock = socket.create_connection((host, port))
[238] Fix | Delete
self.file = self.sock.makefile('rb')
[239] Fix | Delete
[240] Fix | Delete
[241] Fix | Delete
def read(self, size):
[242] Fix | Delete
"""Read 'size' bytes from remote."""
[243] Fix | Delete
return self.file.read(size)
[244] Fix | Delete
[245] Fix | Delete
[246] Fix | Delete
def readline(self):
[247] Fix | Delete
"""Read line from remote."""
[248] Fix | Delete
line = self.file.readline(_MAXLINE + 1)
[249] Fix | Delete
if len(line) > _MAXLINE:
[250] Fix | Delete
raise self.error("got more than %d bytes" % _MAXLINE)
[251] Fix | Delete
return line
[252] Fix | Delete
[253] Fix | Delete
[254] Fix | Delete
def send(self, data):
[255] Fix | Delete
"""Send data to remote."""
[256] Fix | Delete
self.sock.sendall(data)
[257] Fix | Delete
[258] Fix | Delete
[259] Fix | Delete
def shutdown(self):
[260] Fix | Delete
"""Close I/O established in "open"."""
[261] Fix | Delete
self.file.close()
[262] Fix | Delete
try:
[263] Fix | Delete
self.sock.shutdown(socket.SHUT_RDWR)
[264] Fix | Delete
except socket.error as e:
[265] Fix | Delete
# The server might already have closed the connection
[266] Fix | Delete
if e.errno != errno.ENOTCONN:
[267] Fix | Delete
raise
[268] Fix | Delete
finally:
[269] Fix | Delete
self.sock.close()
[270] Fix | Delete
[271] Fix | Delete
[272] Fix | Delete
def socket(self):
[273] Fix | Delete
"""Return socket instance used to connect to IMAP4 server.
[274] Fix | Delete
[275] Fix | Delete
socket = <instance>.socket()
[276] Fix | Delete
"""
[277] Fix | Delete
return self.sock
[278] Fix | Delete
[279] Fix | Delete
[280] Fix | Delete
[281] Fix | Delete
# Utility methods
[282] Fix | Delete
[283] Fix | Delete
[284] Fix | Delete
def recent(self):
[285] Fix | Delete
"""Return most recent 'RECENT' responses if any exist,
[286] Fix | Delete
else prompt server for an update using the 'NOOP' command.
[287] Fix | Delete
[288] Fix | Delete
(typ, [data]) = <instance>.recent()
[289] Fix | Delete
[290] Fix | Delete
'data' is None if no new messages,
[291] Fix | Delete
else list of RECENT responses, most recent last.
[292] Fix | Delete
"""
[293] Fix | Delete
name = 'RECENT'
[294] Fix | Delete
typ, dat = self._untagged_response('OK', [None], name)
[295] Fix | Delete
if dat[-1]:
[296] Fix | Delete
return typ, dat
[297] Fix | Delete
typ, dat = self.noop() # Prod server for response
[298] Fix | Delete
return self._untagged_response(typ, dat, name)
[299] Fix | Delete
[300] Fix | Delete
[301] Fix | Delete
def response(self, code):
[302] Fix | Delete
"""Return data for response 'code' if received, or None.
[303] Fix | Delete
[304] Fix | Delete
Old value for response 'code' is cleared.
[305] Fix | Delete
[306] Fix | Delete
(code, [data]) = <instance>.response(code)
[307] Fix | Delete
"""
[308] Fix | Delete
return self._untagged_response(code, [None], code.upper())
[309] Fix | Delete
[310] Fix | Delete
[311] Fix | Delete
[312] Fix | Delete
# IMAP4 commands
[313] Fix | Delete
[314] Fix | Delete
[315] Fix | Delete
def append(self, mailbox, flags, date_time, message):
[316] Fix | Delete
"""Append message to named mailbox.
[317] Fix | Delete
[318] Fix | Delete
(typ, [data]) = <instance>.append(mailbox, flags, date_time, message)
[319] Fix | Delete
[320] Fix | Delete
All args except `message' can be None.
[321] Fix | Delete
"""
[322] Fix | Delete
name = 'APPEND'
[323] Fix | Delete
if not mailbox:
[324] Fix | Delete
mailbox = 'INBOX'
[325] Fix | Delete
if flags:
[326] Fix | Delete
if (flags[0],flags[-1]) != ('(',')'):
[327] Fix | Delete
flags = '(%s)' % flags
[328] Fix | Delete
else:
[329] Fix | Delete
flags = None
[330] Fix | Delete
if date_time:
[331] Fix | Delete
date_time = Time2Internaldate(date_time)
[332] Fix | Delete
else:
[333] Fix | Delete
date_time = None
[334] Fix | Delete
self.literal = MapCRLF.sub(CRLF, message)
[335] Fix | Delete
return self._simple_command(name, mailbox, flags, date_time)
[336] Fix | Delete
[337] Fix | Delete
[338] Fix | Delete
def authenticate(self, mechanism, authobject):
[339] Fix | Delete
"""Authenticate command - requires response processing.
[340] Fix | Delete
[341] Fix | Delete
'mechanism' specifies which authentication mechanism is to
[342] Fix | Delete
be used - it must appear in <instance>.capabilities in the
[343] Fix | Delete
form AUTH=<mechanism>.
[344] Fix | Delete
[345] Fix | Delete
'authobject' must be a callable object:
[346] Fix | Delete
[347] Fix | Delete
data = authobject(response)
[348] Fix | Delete
[349] Fix | Delete
It will be called to process server continuation responses.
[350] Fix | Delete
It should return data that will be encoded and sent to server.
[351] Fix | Delete
It should return None if the client abort response '*' should
[352] Fix | Delete
be sent instead.
[353] Fix | Delete
"""
[354] Fix | Delete
mech = mechanism.upper()
[355] Fix | Delete
# XXX: shouldn't this code be removed, not commented out?
[356] Fix | Delete
#cap = 'AUTH=%s' % mech
[357] Fix | Delete
#if not cap in self.capabilities: # Let the server decide!
[358] Fix | Delete
# raise self.error("Server doesn't allow %s authentication." % mech)
[359] Fix | Delete
self.literal = _Authenticator(authobject).process
[360] Fix | Delete
typ, dat = self._simple_command('AUTHENTICATE', mech)
[361] Fix | Delete
if typ != 'OK':
[362] Fix | Delete
raise self.error(dat[-1])
[363] Fix | Delete
self.state = 'AUTH'
[364] Fix | Delete
return typ, dat
[365] Fix | Delete
[366] Fix | Delete
[367] Fix | Delete
def capability(self):
[368] Fix | Delete
"""(typ, [data]) = <instance>.capability()
[369] Fix | Delete
Fetch capabilities list from server."""
[370] Fix | Delete
[371] Fix | Delete
name = 'CAPABILITY'
[372] Fix | Delete
typ, dat = self._simple_command(name)
[373] Fix | Delete
return self._untagged_response(typ, dat, name)
[374] Fix | Delete
[375] Fix | Delete
[376] Fix | Delete
def check(self):
[377] Fix | Delete
"""Checkpoint mailbox on server.
[378] Fix | Delete
[379] Fix | Delete
(typ, [data]) = <instance>.check()
[380] Fix | Delete
"""
[381] Fix | Delete
return self._simple_command('CHECK')
[382] Fix | Delete
[383] Fix | Delete
[384] Fix | Delete
def close(self):
[385] Fix | Delete
"""Close currently selected mailbox.
[386] Fix | Delete
[387] Fix | Delete
Deleted messages are removed from writable mailbox.
[388] Fix | Delete
This is the recommended command before 'LOGOUT'.
[389] Fix | Delete
[390] Fix | Delete
(typ, [data]) = <instance>.close()
[391] Fix | Delete
"""
[392] Fix | Delete
try:
[393] Fix | Delete
typ, dat = self._simple_command('CLOSE')
[394] Fix | Delete
finally:
[395] Fix | Delete
self.state = 'AUTH'
[396] Fix | Delete
return typ, dat
[397] Fix | Delete
[398] Fix | Delete
[399] Fix | Delete
def copy(self, message_set, new_mailbox):
[400] Fix | Delete
"""Copy 'message_set' messages onto end of 'new_mailbox'.
[401] Fix | Delete
[402] Fix | Delete
(typ, [data]) = <instance>.copy(message_set, new_mailbox)
[403] Fix | Delete
"""
[404] Fix | Delete
return self._simple_command('COPY', message_set, new_mailbox)
[405] Fix | Delete
[406] Fix | Delete
[407] Fix | Delete
def create(self, mailbox):
[408] Fix | Delete
"""Create new mailbox.
[409] Fix | Delete
[410] Fix | Delete
(typ, [data]) = <instance>.create(mailbox)
[411] Fix | Delete
"""
[412] Fix | Delete
return self._simple_command('CREATE', mailbox)
[413] Fix | Delete
[414] Fix | Delete
[415] Fix | Delete
def delete(self, mailbox):
[416] Fix | Delete
"""Delete old mailbox.
[417] Fix | Delete
[418] Fix | Delete
(typ, [data]) = <instance>.delete(mailbox)
[419] Fix | Delete
"""
[420] Fix | Delete
return self._simple_command('DELETE', mailbox)
[421] Fix | Delete
[422] Fix | Delete
def deleteacl(self, mailbox, who):
[423] Fix | Delete
"""Delete the ACLs (remove any rights) set for who on mailbox.
[424] Fix | Delete
[425] Fix | Delete
(typ, [data]) = <instance>.deleteacl(mailbox, who)
[426] Fix | Delete
"""
[427] Fix | Delete
return self._simple_command('DELETEACL', mailbox, who)
[428] Fix | Delete
[429] Fix | Delete
def expunge(self):
[430] Fix | Delete
"""Permanently remove deleted items from selected mailbox.
[431] Fix | Delete
[432] Fix | Delete
Generates 'EXPUNGE' response for each deleted message.
[433] Fix | Delete
[434] Fix | Delete
(typ, [data]) = <instance>.expunge()
[435] Fix | Delete
[436] Fix | Delete
'data' is list of 'EXPUNGE'd message numbers in order received.
[437] Fix | Delete
"""
[438] Fix | Delete
name = 'EXPUNGE'
[439] Fix | Delete
typ, dat = self._simple_command(name)
[440] Fix | Delete
return self._untagged_response(typ, dat, name)
[441] Fix | Delete
[442] Fix | Delete
[443] Fix | Delete
def fetch(self, message_set, message_parts):
[444] Fix | Delete
"""Fetch (parts of) messages.
[445] Fix | Delete
[446] Fix | Delete
(typ, [data, ...]) = <instance>.fetch(message_set, message_parts)
[447] Fix | Delete
[448] Fix | Delete
'message_parts' should be a string of selected parts
[449] Fix | Delete
enclosed in parentheses, eg: "(UID BODY[TEXT])".
[450] Fix | Delete
[451] Fix | Delete
'data' are tuples of message part envelope and data.
[452] Fix | Delete
"""
[453] Fix | Delete
name = 'FETCH'
[454] Fix | Delete
typ, dat = self._simple_command(name, message_set, message_parts)
[455] Fix | Delete
return self._untagged_response(typ, dat, name)
[456] Fix | Delete
[457] Fix | Delete
[458] Fix | Delete
def getacl(self, mailbox):
[459] Fix | Delete
"""Get the ACLs for a mailbox.
[460] Fix | Delete
[461] Fix | Delete
(typ, [data]) = <instance>.getacl(mailbox)
[462] Fix | Delete
"""
[463] Fix | Delete
typ, dat = self._simple_command('GETACL', mailbox)
[464] Fix | Delete
return self._untagged_response(typ, dat, 'ACL')
[465] Fix | Delete
[466] Fix | Delete
[467] Fix | Delete
def getannotation(self, mailbox, entry, attribute):
[468] Fix | Delete
"""(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
[469] Fix | Delete
Retrieve ANNOTATIONs."""
[470] Fix | Delete
[471] Fix | Delete
typ, dat = self._simple_command('GETANNOTATION', mailbox, entry, attribute)
[472] Fix | Delete
return self._untagged_response(typ, dat, 'ANNOTATION')
[473] Fix | Delete
[474] Fix | Delete
[475] Fix | Delete
def getquota(self, root):
[476] Fix | Delete
"""Get the quota root's resource usage and limits.
[477] Fix | Delete
[478] Fix | Delete
Part of the IMAP4 QUOTA extension defined in rfc2087.
[479] Fix | Delete
[480] Fix | Delete
(typ, [data]) = <instance>.getquota(root)
[481] Fix | Delete
"""
[482] Fix | Delete
typ, dat = self._simple_command('GETQUOTA', root)
[483] Fix | Delete
return self._untagged_response(typ, dat, 'QUOTA')
[484] Fix | Delete
[485] Fix | Delete
[486] Fix | Delete
def getquotaroot(self, mailbox):
[487] Fix | Delete
"""Get the list of quota roots for the named mailbox.
[488] Fix | Delete
[489] Fix | Delete
(typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
[490] Fix | Delete
"""
[491] Fix | Delete
typ, dat = self._simple_command('GETQUOTAROOT', mailbox)
[492] Fix | Delete
typ, quota = self._untagged_response(typ, dat, 'QUOTA')
[493] Fix | Delete
typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT')
[494] Fix | Delete
return typ, [quotaroot, quota]
[495] Fix | Delete
[496] Fix | Delete
[497] Fix | Delete
def list(self, directory='""', pattern='*'):
[498] Fix | Delete
"""List mailbox names in directory matching pattern.
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function