a DOg^;@sjdZddlZddlZddlZddlZzddlZdZWneyJdZYn0ddgZGddde Z dZ d Z d Z d Ze eZd ZGd ddZerGdddeZededkrfddlZeejdZeeeejdeejdee\ZZededD]BZ e!e \Z"Z#Z$ede e#D]Z%ede%q>edqe&dS)z@A POP3 client class. Based on the J. Myers POP3 draft, Jan. 96 NTFPOP3 error_protoc@s eZdZdS)rN)__name__ __module__ __qualname__rr+/opt/alt/python39/lib64/python3.9/poplib.pyrni  ic@s eZdZdZdZeejfddZddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZddZd=d d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zed0Z d1d2Z!d3d4Z"d>d5d6Z#d7d8Z$d9d:Z%d?d;d<Z&dS)@raPThis class supports both the minimal and optional command sets. Arguments can be strings or integers (where appropriate) (e.g.: retr(1) and retr('1') both work equally well. Minimal Command Set: USER name user(name) PASS string pass_(string) STAT stat() LIST [msg] list(msg = None) RETR msg retr(msg) DELE msg dele(msg) NOOP noop() RSET rset() QUIT quit() Optional Commands (some servers support these): RPOP name rpop(name) APOP name digest apop(name, digest) TOP msg n top(msg, n) UIDL [msg] uidl(msg = None) CAPA capa() STLS stls() UTF8 utf8() Raises one exception: 'error_proto'. Instantiate with: POP3(hostname, port=110) NB: the POP protocol locks the mailbox from user authorization until QUIT, so be sure to get in, suck the messages, and quit, each time you access the mailbox. POP is a line-based protocol, which means large mail messages consume lots of python cycles reading them line-by-line. If it's available on your mail server, use IMAP4 instead, it doesn't suffer from the two problems above. zUTF-8cCsP||_||_d|_td||||||_|jd|_d|_ | |_ dS)NFzpoplib.connectrbr) hostport_tls_establishedsysaudit_create_socketsockmakefilefile _debugging_getrespwelcome)selfrrtimeoutrrr__init__bs z POP3.__init__cCs(|dur|stdt|j|jf|S)Nz0Non-blocking socket (timeout=0) is not supported) ValueErrorsocketZcreate_connectionrr)rrrrrrms zPOP3._create_socketcCs:|jdkrtdt|td|||j|tdS)Nz*put*zpoplib.putline)rprintreprrrrZsendallCRLFrlinerrr_putlinersz POP3._putlinecCs.|jrtdt|t||j}||dS)Nz*cmd*)rr r!bytesencodingr%r#rrr_putcmdzs z POP3._putcmdcCs|jtd}t|tkr$td|jdkr)cCs\t||j}|j|j}|s&tdddl}|d|}|| }| d||fS)a Authorisation - only possible if server has supplied a timestamp in initial greeting. Args: user - mailbox user; password - mailbox password. NB: mailbox is locked by server from here to 'quit()' z!-ERR APOP not supported by serverrNrz APOP %s %s) r&r' timestampmatchrrhashlibgroupZmd5Z hexdigestr:)rrBZpasswordZsecretmrYZdigestrrrapop>s z POP3.apopcCs|d||fS)zRetrieve message header of message number 'which' and first 'howmuch' lines of message body. Result is in form ['response', ['line', ...], octets]. z TOP %s %srK)rrJZhowmuchrrrtopSszPOP3.topcCs |dur|d|S|dS)zReturn message digest (unique id) list. If 'which', result contains unique id for that message in the form 'response mesgnum uid', otherwise result is the list ['response', ['mesgnum uid', ...], octets] NzUIDL %sZUIDLrHrIrrruidl\sz POP3.uidlcCs |dS)zITry to enter UTF-8 mode (see RFC 6856). Returns server response. ZUTF8r@r<rrrutf8hsz POP3.utf8cCs`dd}i}z4|d}|d}|D]}||\}}|||<q$WntyZtdYn0|S)aReturn server capabilities (RFC 2449) as a dictionary >>> c=poplib.POP3('localhost') >>> c.capa() {'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'], 'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [], 'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [], 'UIDL': [], 'RESP-CODES': []} >>> Really, according to RFC 2449, the cyrus folks should avoid having the implementation split into multiple arguments... cSs"|d}|d|ddfS)Nasciirr)decoderE)r$Zlstrrr _parsecap{szPOP3.capa.._parsecapZCAPArz!-ERR CAPA not supported by server)r;r)rrbcapsr3ZrawcapsZcaplineZcapnmZcapargsrrrcapans    z POP3.capacCsxts td|jrtd|}d|vr2td|durBt}|d}|j|j|j d|_|j d|_ d|_|S) z{Start a TLS session on the active connection as specified in RFC 2595. context - a ssl.SSLContext z-ERR TLS support missing$-ERR TLS session already establishedZSTLSz!-ERR STLS not supported by serverNZserver_hostnamer T) HAVE_SSLrrrdssl_create_stdlib_contextr: wrap_socketrrrr)rcontextrcr3rrrstlss  z POP3.stls)N)N)N)'rrr__doc__r' POP3_PORTr_GLOBAL_DEFAULT_TIMEOUTrrr%r(r0rr8r:r;r=r?rBrCrGr7rLrMrNrOrQrPrVrecompilerWr\r]r^r_rdrlrrrrr3sB+       c@s8eZdZdZeddejdfddZddZd ddZ dS) POP3_SSLaPOP3 client class over SSL connection Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None, context=None) hostname - the hostname of the pop3 over ssl server port - port number keyfile - PEM formatted file that contains your private key certfile - PEM formatted certificate chain file context - a ssl.SSLContext See the methods of the parent class POP3 for more documentation. NcCs|dur|durtd|dur0|dur0td|dus@|durVddl}|dtd||_||_|durxtj||d}||_t ||||dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadrD)certfilekeyfile) rwarningswarnDeprecationWarningrtrsrhrirkrr)rrrrtrsrrkrurrrrs"zPOP3_SSL.__init__cCs"t||}|jj||jd}|S)Nrf)rrrkrjr)rrrrrrrs  zPOP3_SSL._create_socketcCs tddS)zThe method unconditionally raises an exception since the STLS command doesn't make any sense on an already established SSL/TLS session. reN)r)rrtrsrkrrrrlsz POP3_SSL.stls)NNN) rrrrm POP3_SSL_PORTrrorrrlrrrrrrs  rr__main__rrDz Message %d:z z-----------------------)'rmrSrprrrhrg ImportError__all__ Exceptionrrnrxr.ZLFr"r,rrrr6rargvar r=rBrCr7rGZnumMsgsZ totalSizerangeirLheadermsgr/r$rQrrrrsL  p0