hdrlines self decodefulltext(hdrlinesallhdrs append('\njoin(hdrlines)finallyserver quit(assert len(allhdrs=len(allsizesself trace('load headers exit'return allhdrsallsizesfalse make sure unlock mbox def downloadallmessages(selfprogress=noneloadfrom= )""load full message text for all msgs from loadfrom ndespite any caching that may be being done in the callermuch slower than downloadallheadersif just need hdrs esupport mailconfig fetchlimitsee downloadallheaderscould use server list(to get sizes of skipped emails here toobut clients probably don' care about these anyhow""self trace('loading full messages'fetchlimit mailconfig fetchlimit server self connect(try(msgcountmsgbytesserver stat(inbox on server allmsgs [allsizes [for in range(loadfrommsgcount+ )empty if low >high if progressprogress(imsgcountif fetchlimit and ( <msgcount fetchlimit)skipadd dummy mail mailtext 'subject--mail skipped--\ \nmail skipped \nallmsgs append(mailtextallsizes append(len(mailtext)elsefetchretr full mail (respmessagerespszserver retr(isave text on list message self decodefulltext(messageallmsgs append('\njoin(message)leave mail on server allsizes append(respszdiff from len(msgfinallyserver quit(unlock the mail box assert len(allmsgs=(msgcount loadfrom msg nums start at #assert sum(allsizes=msgbytes not if loadfrom return allmsgsallsizestrue not if fetchlimit def deletemessages(selfmsgnumsprogress=none)""delete multiple msgs off serverassumes email inbox unchanged since msgnums were last determined/loadeduse if msg headers not available as state informationfastbut poss dangeroussee deletemessagessafely ""self trace('deleting mails'server self connect(try client-side scripting