import cgi import loadmailcommonhtml from externs import mailtools from secret import encode maxhdr user-defined encoder module max length of email hdrs in list only pswd comes from page hererest usually in module formdata cgi fieldstorage(mailusermailpswdmailsite commonhtml getstandardpopfields(formdataparser mailtools mailparser(trynewmails loadmail loadmailhdrs(mailsitemailusermailpswdmailnum maillist [or use enumerate(for mail in newmailslist of hdr text msginfo [hdrs parser parseheaders(mailemail message message addrhdrs ('from''to''cc''bcc'decode names only for key in ('subject''from''date')rawhdr hdrs get(key'?'if key not in addrhdrsdechdr parser decodeheader(rawhdr decode for display elseencoded on sends dechdr parser decodeaddrheader(rawhdremail names only msginfo append(dechdr[:maxhdr]msginfo join(msginfomaillist append((msginfocommonhtml urlroot 'onviewlistlink py'{'mnum'mailnum'user'mailuserdata params 'pswd'encode(mailpswd)pass in url 'site'mailsite})not inputs mailnum + commonhtml listpage(maillist'mail selection list'exceptcommonhtml errorpage('error loading mail index'this script' main purpose is to generate selection list page for the user' email accountusing the password typed into the prior page (or passed in urlas usual with encapsulationmost of the details are hidden in other filesloadmail loadmailhdrs reuses the mailtools module package from to fetch email with the pop protocolwe need message count and mail headers here to display an index list in this versionthe software fetches only mail header text to save timenot full mail messages (provided your server supports the top command of the pop interfaceand most do--if notsee mailconfig to disable this the pymailcgi server