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