these tools are useful only to clients that retain the fetched email list as state information we'll use these in the pymailgui client in theredeletions use the safe interfaceand loads run the on-demand synchronization teston detection of synchronization errorsthe inbox index is automatically reloaded for nowsee example - source code and comments for more details note that the synchronization tests try variety of matching techniquesbut require the complete headers text andin the worst casemust parse headers and match many header fields in many casesthe single previously fetched message-id header field would be sufficient for matching against messages in the server' inbox howeverbecause this field is optional and can be forged to have any valueit might not always be reliable way to identify messages in other wordsa same-valued message-id may not suffice to guarantee matchalthough it can be used to identify mismatchin example - the message-id is used to rule out match if either message has oneand they differ in value this test is performed before falling back on slower parsing and multiple header matches example - pp \internet\email\mailtools\mailfetcher py ""##############################################################################retrievedeletematch mail from pop server (see __init__ for docstest##############################################################################""import poplibmailconfigsys print('user:'mailconfig popusernameclient' mailconfig on sys path script dirpythonpathchanges from mailparser import mailparser from mailtool import mailtoolsilentmailtool for headers matching ( etrace control supers ( eindex/server msgnum out of synch tests class deletesyncherror(exception)pass class topnotsupported(exception)pass class messagesyncherror(exception)pass msg out of synch in del can' run synch test index list out of sync class mailfetcher(mailtool)""fetch mailconnectfetch headers+mailsdelete mails works on any machine with python+inetsubclass me to cache implemented with the pop protocolimap requires new class ehandles decoding of full mail text on fetch for parser""def __init__(selfpopserver=nonepopuser=nonepoppswd=nonehastop=true)self popserver popserver or mailconfig popservername self popuser popuser or mailconfig popusername self srvrhastop hastop self poppassword poppswd ask later if none the mailtools utility package