B *ÛE7Û[Õã @slddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Zddddddd d d d d ddg ZdZdZdZdZdZe dej¡ZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZGdd „d eƒZ Gdd „d eƒZ!Gdd „d eƒZ"d d „Z#d!d"„Z$d#d„Z%d$d%„Z&d&d'„Z'y ddl(Z(Wne)k r’d(Z*YnXd)Z*Gd*d„dƒZ+e*rÆGd+d,„d,e+ƒZ,e -d,¡d-Z.Gd.d/„d/e+ƒZ/e0d0krhd1d2„Z1e1d3ƒZ2e1d4ƒ 3d5¡Z4e5d6ƒd7Z6x e j7 8¡Z9e9s"Pe6e9Z6qWe5d8e:e6ƒƒe+d9ƒZ;e; ¡dS);éN)Ú body_encodeÚ SMTPExceptionÚSMTPNotSupportedErrorÚSMTPServerDisconnectedÚSMTPResponseExceptionÚSMTPSenderRefusedÚSMTPRecipientsRefusedÚ SMTPDataErrorÚSMTPConnectErrorÚ SMTPHeloErrorÚSMTPAuthenticationErrorÚ quoteaddrÚ quotedataÚSMTPéiÑz s i z auth=(.*)c@s eZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©rrú*/opt/alt/python37/lib/python3.7/smtplib.pyrGsc@s eZdZdS)rN)rrrrrrrrJsc@s eZdZdS)rN)rrrrrrrrQsc@seZdZdd„ZdS)rcCs||_||_||f|_dS)N)Ú smtp_codeÚ smtp_errorÚargs)ÚselfÚcodeÚmsgrrrÚ__init__bszSMTPResponseException.__init__N)rrrrrrrrrYs c@seZdZdd„ZdS)rcCs"||_||_||_|||f|_dS)N)rrÚsenderr)rrrrrrrrnszSMTPSenderRefused.__init__N)rrrrrrrrrgsc@seZdZdd„ZdS)rcCs||_|f|_dS)N)Ú recipientsr)rrrrrr|szSMTPRecipientsRefused.__init__N)rrrrrrrrrtsc@s eZdZdS)r N)rrrrrrrr sc@s eZdZdS)r N)rrrrrrrr „sc@s eZdZdS)r N)rrrrrrrr ‡sc@s eZdZdS)r N)rrrrrrrr ŠscCs>tj |¡\}}||fdkr6| ¡ d¡r.|Sd|Sd|S)N)Úrú)ÚemailÚutilsÚ parseaddrÚstripÚ startswith)Ú addrstringÚ displaynameÚaddrrrrr ‘s  cCs$tj |¡\}}||fdkr |S|S)N)rr)r!r"r#)r&r'r(rrrÚ _addr_onlyžs r)c Cst ddt dt|¡¡S)Nz(?m)^\.z..z(?:\r\n|\n|\r(?!\n)))ÚreÚsubÚCRLF)Údatarrrr¦scCst dd|¡S)Ns(?m)^\.s..)r*r+)ZbindatarrrÚ_quote_periods¯sr.cCst dt|¡S)Nz(?:\r\n|\n|\r(?!\n)))r*r+r,)r-rrrÚ _fix_eols²sr/FTc@sreZdZdZdZdZdZdZdZe Z ddde j dfdd„Z dd„Zd d „Zd d „Zd d„Zdd„ZdMdd„Zdd„ZdNdd„Zdd„ZdOdd„ZdPdd„ZdQdd„Zd d!„ZdRd"d#„Zd$d%„Zd&d'„Zd(d)„ZdSd+d,„ZdTd-d.„Z d/d0„Z!d1d2„Z"e"Z#d3d4„Z$d5d6„Z%d7d8œd9d:„Z&dUd;d<„Z'dVd=d>„Z(dWd?d@„Z)d7d8œdAdB„Z*dXdCdD„Z+dYdEdF„Z,dZdGdH„Z-dIdJ„Z.dKdL„Z/dS)[rrNÚehlorc Cs°||_||_i|_d|_||_|rL| ||¡\}}|dkrL| ¡t||ƒ‚|dk r\||_nPt   ¡}d|krt||_n8d} yt   t   ¡¡} Wnt j k r YnXd| |_dS)NÚasciiéÜÚ.z 127.0.0.1z[%s])Ú_hostÚtimeoutÚesmtp_featuresÚcommand_encodingÚsource_addressÚconnectÚcloser Úlocal_hostnameÚsocketZgetfqdnZ gethostbynameZ gethostnameZgaierror) rÚhostÚportr;r5r8rrZfqdnr(rrrrâs* z SMTP.__init__cCs|S)Nr)rrrrÚ __enter__szSMTP.__enter__cGsNz>y$| d¡\}}|dkr$t||ƒ‚Wntk r:YnXWd| ¡XdS)NZQUITéÝ)Údocmdrrr:)rrrÚmessagerrrÚ__exit__s z SMTP.__exit__cCs ||_dS)N)Ú debuglevel)rrDrrrÚset_debuglevelszSMTP.set_debuglevelcGs@|jdkr,ttj ¡ ¡f|ždtjiŽnt|dtjiŽdS)NéÚfile)rDÚprintÚdatetimeZnowZtimeÚsysÚstderr)rrrrrÚ _print_debug's "zSMTP._print_debugcCs2|jdkr| d||f|j¡t ||f||j¡S)Nrz connect: to)rDrLr8r<Úcreate_connection)rr=r>r5rrrÚ _get_socket-s  zSMTP._get_socketÚ localhostcCsæ|r ||_|s|| d¡| d¡kr|| d¡}|dkr||d|…||dd…}}y t|ƒ}Wntk rztdƒ‚YnX|s†|j}|jdkr | d||f¡|  |||j ¡|_ d|_ |  ¡\}}|jdkrÞ| dt|ƒ¡||fS)Nú:rrFznonnumeric portzconnect:)r8ÚfindÚrfindÚintÚ ValueErrorÚOSErrorÚ default_portrDrLrNr5ÚsockrGÚgetreplyÚrepr)rr=r>r8Úirrrrrr95s(      z SMTP.connectcCs„|jdkr| dt|ƒ¡t|dƒrx|jrxt|tƒr@| |j¡}y|j  |¡Wq€t k rt|  ¡t dƒ‚Yq€Xnt dƒ‚dS)Nrzsend:rWzServer not connectedzplease run connect() first) rDrLrYÚhasattrrWÚ isinstanceÚstrÚencoder7ZsendallrUr:r)rÚsrrrÚsendWs   z SMTP.sendcCsd|dkr|}n|›d|›}d|ks,d|krN| dd¡ dd¡}td|›ƒ‚| |›t›¡dS)Nrú ú Ú z\nz\rz=command and arguments contain prohibited newline characters: )ÚreplacerTr`r,)rÚcmdrr_rrrÚputcmdis z SMTP.putcmdc CsPg}|jdkr|j d¡|_xy|j td¡}Wn:tk rn}z| ¡tdt|ƒƒ‚Wdd}~XYnX|s„| ¡tdƒ‚|j dkrž|  dt |ƒ¡t |ƒtkr¼| ¡t ddƒ‚| |d d… d ¡¡|dd …}y t|ƒ}Wntk rd }PYnX|d d …d kr Pq Wd |¡}|j dkrH|  d||f¡||fS)NÚrbrFz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:iôzLine too long.és ééÿÿÿÿó-ó zreply: retcode (%s); Msg: %a)rGrWZmakefileÚreadlineÚ_MAXLINErUr:rr]rDrLrYÚlenrÚappendr$rSrTÚjoin)rÚrespÚlineÚerZerrcodeÚerrmsgrrrrXvs>         z SMTP.getreplycCs| ||¡| ¡S)N)rfrX)rrerrrrrA§s z SMTP.docmdcCs,| d|p|j¡| ¡\}}||_||fS)NÚhelo)rfr;rXÚ helo_resp)rÚnamerrrrrrv­s z SMTP.heloc Cs2i|_| |j|p|j¡| ¡\}}|dkrJt|ƒdkrJ| ¡tdƒ‚||_|dkr`||fSd|_ |j  d¡  d¡}|d=xª|D]¢}t   |¡}|r¾|j dd ¡d | d¡d|jd<q„t  d |¡}|r„| d ¡ ¡}|j| d ¡d… ¡} |dkr|j |d ¡d | |j|<q„| |j|<q„W||fS) NrjrzServer not connectedéúrFzlatin-1rcÚauthrraz((?P[A-Za-z0-9][A-Za-z0-9\-]*) ?Úfeature)r6rfÚehlo_msgr;rXror:rÚ ehlo_respÚ does_esmtpÚdecodeÚsplitÚ OLDSTYLE_AUTHÚmatchÚgetÚgroupsr*ÚgroupÚlowerÚstringÚendr$) rrxrrrrÚeachZ auth_matchÚmr{Úparamsrrrr0·s2   &  z SMTP.ehlocCs| ¡|jkS)N)r†r6)rÚoptrrrÚhas_extnêsz SMTP.has_extncCs| d|¡| ¡dS)NÚhelprF)rfrX)rrrrrrŽîs z SMTP.helpcCsd|_| d¡S)Nr1Úrset)r7rA)rrrrrôsz SMTP.rsetcCs&y | ¡Wntk r YnXdS)N)rr)rrrrÚ_rsetùs z SMTP._rsetcCs | d¡S)NÚnoop)rA)rrrrr‘sz SMTP.nooprcCshd}|rH|jrHtdd„|Dƒƒr:| d¡r2d|_ntdƒ‚dd |¡}| dd t|ƒ|f¡| ¡S) Nrcss|]}| ¡dkVqdS)Úsmtputf8N)r†)Ú.0Úxrrrú szSMTP.mail..r’zutf-8z SMTPUTF8 not supported by serverraÚmailz FROM:%s%s) r~Úanyrr7rrqrfr rX)rrÚoptionsÚ optionlistrrrr– s   z SMTP.mailcCs<d}|r|jrdd |¡}| ddt|ƒ|f¡| ¡S)NrraÚrcptzTO:%s%s)r~rqrfr rX)rZrecipr˜r™rrrršs  z SMTP.rcptcCsÄ| d¡| ¡\}}|jdkr0| d||f¡|dkrDt||ƒ‚n|t|tƒr\t|ƒ d¡}t |ƒ}|dd…t kr||t }|dt }|  |¡| ¡\}}|jdkr¸| d||f¡||fSdS)Nr-rzdata:ibr1éþÿÿÿó.) rfrXrDrLr r\r]r/r^r.ÚbCRLFr`)rrrÚreplÚqrrrr-&s"         z SMTP.datacCs| dt|ƒ¡| ¡S)NÚvrfy)rfr)rX)rÚaddressrrrÚverifyCsz SMTP.verifycCs| dt|ƒ¡| ¡S)NÚexpn)rfr)rX)rr¡rrrr£Jsz SMTP.expncCsb|jdkr^|jdkr^d| ¡dkr0dks^n| ¡\}}d|krRdks^nt||ƒ‚dS)NéÈri+)rwr}r0rvr )rrrrrrrÚehlo_or_helo_if_neededQs  zSMTP.ehlo_or_helo_if_neededT)Úinitial_response_okc Cs®| ¡}|r|ƒnd}|dk rJt| d¡dd}| d|d|¡\}}n| d|¡\}}|dkrt |¡}t||ƒ d¡dd}| |¡\}}|dkr ||fSt||ƒ‚dS)Nr1r)ZeolZAUTHraiN)éëi÷)ÚupperÚ encode_base64r^rAÚbase64Z decodebytesr ) rZ mechanismZ authobjectr¦Zinitial_responseZresponserrrÚ challengerrrrzbs z SMTP.authcCs0|dkr dS|jdt |j d¡|d¡ ¡S)Nrar1Zmd5)ÚuserÚhmacZHMACÚpasswordr^Z hexdigest)rr«rrrÚ auth_cram_md5‰s zSMTP.auth_cram_md5cCsd|j|jfS)Nz%s%s)r¬r®)rr«rrrÚ auth_plain’szSMTP.auth_plaincCs|dkr|jS|jSdS)N)r¬r®)rr«rrrÚ auth_login—szSMTP.auth_loginc sÞ| ¡| d¡stdƒ‚|jd ¡‰dddg}‡fdd„|Dƒ}|sPtdƒ‚|||_|_xv|D]n}d | ¡  d d ¡}y.|j |t ||ƒ|d \}} |d kr¨|| fSWqdt k rÐ} z| } Wdd} ~ XYqdXqdW| ‚dS)Nrzz,SMTP AUTH extension not supported by server.zCRAM-MD5ZPLAINZLOGINcsg|]}|ˆkr|‘qSrr)r“rz)Úadvertised_authlistrrú ÈszSMTP.login..z(No suitable authentication method found.Zauth_ú-Ú_)r¦)r§i÷) r¥rrr6r€rr¬r®r†rdrzÚgetattrr ) rr¬r®r¦Zpreferred_authsZauthlistZ authmethodZ method_namerrrrtZlast_exceptionr)r²rÚloginŸs*      z SMTP.logincCsî| ¡| d¡stdƒ‚| d¡\}}|dkrÜts.ÚToZBccZCccSsg|] }|d‘qS)rFr)r“Úarrrr³³sz Resent-BccFr1r’z”One or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)Úutf8)ÚpolicyÚSMTPUTF8ú BODY=8BITMIMEz )Úlinesep)rÔrÕ)r¥Zget_allrorTr!r"Z getaddressesÚcopyrqr^ÚUnicodeEncodeErrorrrÚioÚBytesIOÚ generatorZBytesGeneratorrÓZcloneZflattenÚgetvaluerÍ)rrrÈrÉrÊrËZresentZ header_prefixZ addr_fieldsZmsg_copyÚ internationalZbytesmsgÚgZflatmsgrrrÚ send_messagesJ           zSMTP.send_messagecCs<z|j}d|_|r| ¡Wd|j}d|_|r6| ¡XdS)N)rGr:rW)rrGrWrrrr:Îs z SMTP.closecCs.| d¡}d|_|_i|_d|_| ¡|S)NÚquitF)rAr}rwr6r~r:)rZresrrrràÛs   z SMTP.quit)rOrN)r)r)r)r)r)r)r)N)N)N)NNN)rr)NNrr)0rrrrDrGrwr|r}r~Ú SMTP_PORTrVr<Ú_GLOBAL_DEFAULT_TIMEOUTrr?rCrErLrNr9r`rfrXrArvr0rrŽrrr‘r–ršr-r¢r r£r¥rzr¯r°r±r·r¸rÍrßr:ràrrrrr½s\ -   " 1  3    '  B 8 g L c@s4eZdZeZdddddejddfdd„Zdd„ZdS)ÚSMTP_SSLrrNc Cs–|dk r|dk rtdƒ‚|dk r0|dk r0tdƒ‚|dk s@|dk rVddl} |  dtd¡||_||_|dkrxtj||d}||_t   ||||||¡dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadr¹)rºr») rTr¿rÀrÁr»rºrÂrÃrÅrr) rr=r>r;r»rºr5r8rÅr¿rrrr÷s zSMTP_SSL.__init__cCsD|jdkr| d||f¡t ||f||j¡}|jj||jd}|S)Nrzconnect:)r¼)rDrLr<rMr8rÅrÄr4)rr=r>r5Z new_socketrrrrNs   zSMTP_SSL._get_socket) rrrÚ SMTP_SSL_PORTrVr<rârrNrrrrrãçs rãiÓc@s,eZdZdZdeddfdd„Zd dd „ZdS) ÚLMTPZlhlorNcCstj|||||ddS)N)r;r8)rr)rr=r>r;r8rrrr.s z LMTP.__init__rOrcCs´|ddkrtj||||dSy(t tjtj¡|_d|_|j |¡WnBtk rˆ|jdkrl|  d|¡|jr||j  ¡d|_‚YnX|  ¡\}}|jdkr¬|  d|¡||fS)Nrú/)r8z connect fail:zconnect:) rr9r<ZAF_UNIXZ SOCK_STREAMrWrGrUrDrLr:rX)rr=r>r8rrrrrr94s"       z LMTP.connect)rOrN)rrrr|Ú LMTP_PORTrr9rrrrrås råÚ__main__cCs(tj |d¡tj ¡tj ¡ ¡S)Nz: )rJÚstdoutÚwriteÚflushÚstdinrmr$)ÚpromptrrrríNs rírÎrÐú,zEnter message, end with ^D:rzMessage length is %drOrF)?r<rÙr*Z email.utilsr!Z email.messageZemail.generatorrªr­r×rIrJZemail.base64mimerr©Ú__all__rárär,rrnÚcompileÚIrrUrrrrrrr r r r r r)rr.r/rÂÚ ImportErrorr½rrãrprçrårríZfromaddrr€ZtoaddrsrHrrìrmrsroZserverrErÍràrrrrÚ,sŠ        .0 /