Your IP : 52.15.191.241


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/smtplib.cpython-39.opt-2.pyc

a

R�fj��@sVddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Zgd�ZdZdZdZdZdZd	Ze�d
ej�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#dd �Z$d!d"�Z%d#d$�Z&d%d&�Z'd'd(�Z(zddl)Z)Wne*�y~d)Z+Yn0d*Z+Gd+d,�d,�Z,e+�r�Gd-d.�d.e,�Z-e�.d.�d/Z/Gd0d1�d1e,�Z0e1d2k�rRd3d4�Z2e2d5�Z3e2d6��4d7�Z5e6d8�d9Z7ej8�9�Z:e:�s�qe7e:Z7�q�e6d:e;e7��e,d;�Z<e<�=d<�e<�>e3e5e7�e<�?�dS)=�N)�body_encode)
�
SMTPException�SMTPNotSupportedError�SMTPServerDisconnected�SMTPResponseException�SMTPSenderRefused�SMTPRecipientsRefused�
SMTPDataError�SMTPConnectError�
SMTPHeloError�SMTPAuthenticationError�	quoteaddr�	quotedata�SMTP�i��
s
i �z	auth=(.*)c@seZdZdS)rN��__name__�
__module__�__qualname__�rr�,/opt/alt/python39/lib64/python3.9/smtplib.pyrHsrc@seZdZdS)rNrrrrrrKsrc@seZdZdS)rNrrrrrrRsrc@seZdZdd�ZdS)rcCs||_||_||f|_dS�N)�	smtp_code�
smtp_error�args)�self�code�msgrrr�__init__cszSMTPResponseException.__init__N�rrrr rrrrrZs	rc@seZdZdd�ZdS)rcCs"||_||_||_|||f|_dSr)rr�senderr)rrrr"rrrr oszSMTPSenderRefused.__init__Nr!rrrrrhsrc@seZdZdd�ZdS)rcCs||_|f|_dSr)�
recipientsr)rr#rrrr }szSMTPRecipientsRefused.__init__Nr!rrrrrusrc@seZdZdS)r	Nrrrrrr	�sr	c@seZdZdS)r
Nrrrrrr
�sr
c@seZdZdS)rNrrrrrr�src@seZdZdS)rNrrrrrr�srcCs>tj�|�\}}||fdkr6|���d�r.|Sd|Sd|S)N��r%�<z<%s>)�email�utils�	parseaddr�strip�
startswith�Z
addrstringZdisplayname�addrrrrr
�sr
cCs$tj�|�\}}||fdkr |S|S)Nr$)r'r(r)r,rrr�
_addr_only�sr.c	Cst�ddt�dt|��S)Nz(?m)^\.z..�(?:\r\n|\n|\r(?!\n))��re�sub�CRLF��datarrrr�s�rcCst�dd|�S)Ns(?m)^\.s..)r1r2)Zbindatarrr�_quote_periods�sr6cCst�dt|�S)Nr/r0r4rrr�	_fix_eols�sr7FTc@sveZdZdZdZdZdZdZdZdZ	e
Zdddej
dfdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�ZdMdd�Zdd�ZdNdd�Zdd�ZdOdd�ZdPdd�ZdQdd�Zd d!�ZdRd"d#�Zd$d%�Zd&d'�Zd(d)�ZdSd+d,�Z dTd-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�Z0dS)[rrN�ehlor%c
Cs�||_||_i|_d|_||_d|_|rR|�||�\}}|dkrR|��t||��|durb||_	nNt
��}d|vrz||_	n6d}	zt
�t
�
��}	Wnt
jy�Yn0d|	|_	dS)N�asciir���.z	127.0.0.1z[%s])�_host�timeout�esmtp_features�command_encoding�source_address�_auth_challenge_count�connect�closer
�local_hostname�socketZgetfqdnZ
gethostbynameZgethostnameZgaierror)
r�host�portrDr=r@rrZfqdnr-rrrr �s,
z
SMTP.__init__cCs|Srr�rrrr�	__enter__szSMTP.__enter__cGsTzDz$|�d�\}}|dkr$t||��Wnty8Yn0W|��n
|��0dS)NZQUIT��)�docmdrrrC)rrr�messagerrr�__exit__sz
SMTP.__exit__cCs
||_dSr)�
debuglevel)rrNrrr�set_debuglevel"szSMTP.set_debuglevelcGsB|jdkr.ttj����g|�Rdtji�nt|dtji�dS)N��file)rN�print�datetimeZnow�time�sys�stderr�rrrrr�_print_debug+s
$zSMTP._print_debugcCsF|dur|std��|jdkr2|�d||f|j�t�||f||j�S)N�0Non-blocking socket (timeout=0) is not supportedrzconnect: to)�
ValueErrorrNrXr@rEZcreate_connection)rrFrGr=rrr�_get_socket1s
�zSMTP._get_socket�	localhostcCs�|r
||_|sz|�d�|�d�krz|�d�}|dkrz|d|�||dd�}}zt|�}Wntyxtd��Yn0|s�|j}t�d|||�|�	|||j
�|_d|_|�
�\}}|jdkr�|�dt|��||fS)N�:rrPznonnumeric portzsmtplib.connect�connect:)r@�find�rfind�intrZ�OSError�default_portrU�auditr[r=�sockrQ�getreplyrNrX�repr)rrFrGr@�irrrrrrB;s&

zSMTP.connectcCs�|jdkr|�dt|��|jrzt|t�r6|�|j�}t�	d||�z|j�
|�Wq�tyv|��t
d��Yq�0nt
d��dS)Nrzsend:zsmtplib.send�Server not connectedzplease run connect() first)rNrXrgre�
isinstance�str�encoder?rUrdZsendallrbrCr)r�srrr�send\s

z	SMTP.sendcCsd|dkr|}n|�d|��}d|vs,d|vrN|�dd��dd�}td|����|�|�t���dS)Nr%� �
�
z\nz\rz=command and arguments contain prohibited newline characters: )�replacerZrnr3)r�cmdrrmrrr�putcmdos�zSMTP.putcmdc
CsPg}|jdur|j�d�|_z|j�td�}Wn<tyl}z$|��tdt|���WYd}~n
d}~00|s�|��td��|j	dkr�|�
dt|��t|�tkr�|��t
dd��|�|d	d��d
��|dd�}zt|�}Wnt�yd}Y�q Yn0|dd	�d
kr�q qd�|�}|j	dk�rH|�
d||f�||fS)N�rbrPz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:i�zLine too long.�s 	
�����-�
zreply: retcode (%s); Msg: %a)rQreZmakefile�readline�_MAXLINErbrCrrkrNrXrg�lenr�appendr*rarZ�join)r�resp�line�erZerrcode�errmsgrrrrf|s>

�


z
SMTP.getreplycCs|�||�|��Sr�rtrf)rrsrrrrrK�sz
SMTP.docmdcCs,|�d|p|j�|��\}}||_||fS)N�helo)rtrDrf�	helo_resp)r�namerrrrrr��sz	SMTP.heloc
Cs.i|_|�|j|p|j�|��\}}|dkrJt|�dkrJ|��td��||_|dkr`||fSd|_	|j�
d��d�}|d=|D]�}t�
|�}|r�|j�dd	�d
|�d�d|jd<q�t�
d|�}|r�|�d���}|j|�d�d���}	|dk�r|j�|d	�d
|	|j|<q�|	|j|<q�||fS)
Nrxrri�rPzlatin-1rq�authr%roz((?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?�feature)r>rt�ehlo_msgrDrfr}rCr�	ehlo_resp�
does_esmtp�decode�split�
OLDSTYLE_AUTH�match�get�groupsr1�group�lower�string�endr*)
rr�rrr��eachZ
auth_match�mr��paramsrrrr8�sB
��

��z	SMTP.ehlocCs|��|jvSr)r�r>)r�optrrr�has_extn�sz
SMTP.has_extncCs|�d|�|��dS)N�helprPr�rWrrrr��sz	SMTP.helpcCsd|_|�d�S)Nr9�rset)r?rKrHrrrr��sz	SMTP.rsetcCs$z|��WntyYn0dSr)r�rrHrrr�_rset�sz
SMTP._rsetcCs
|�d�S)N�noop)rKrHrrrr�sz	SMTP.nooprcCshd}|rH|jrHtdd�|D��r:|�d�r2d|_ntd��dd�|�}|�dd	t|�|f�|��S)
Nr%css|]}|��dkVqdS)�smtputf8N)r�)�.0�xrrr�	<genexpr>�zSMTP.mail.<locals>.<genexpr>r�zutf-8z SMTPUTF8 not supported by serverro�mailz	FROM:%s%s)	r��anyr�r?rrrtr
rf)rr"�options�
optionlistrrrr�s	

�z	SMTP.mailcCs<d}|r|jrdd�|�}|�ddt|�|f�|��S)Nr%ro�rcptzTO:%s%s)r�rrtr
rf)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)Nr5rzdata:ibr9����.)rtrfrNrXr	rjrkr7rlr6�bCRLFrn)rrr�repl�qrrrr5,s"





z	SMTP.datacCs|�dt|��|��S)N�vrfy�rtr.rf�rZaddressrrr�verifyIszSMTP.verifycCs|�dt|��|��S)N�expnr�r�rrrr�Psz	SMTP.expncCsb|jdur^|jdur^d|��dkr0dks^n|��\}}d|krRdks^nt||��dS)N��ri+)r�r�r8r�r)rrr�rrr�ehlo_or_helo_if_neededWs
zSMTP.ehlo_or_helo_if_neededT��initial_response_okc	Cs�|��}|r|�nd}|durPt|�d�dd�}|�d|d|�\}}d|_n|�d|�\}}d|_|dkr�|jd7_t�|�}t||��d�dd�}|�|�\}}|jtkrftd	t	||f���qf|d
vr�||fSt
||��dS)Nr9r%)ZeolZAUTHrorPriNz4Server AUTH mechanism infinite loop. Last response: ���i�)�upper�
encode_base64rlrKrA�base64Zdecodebytes�
_MAXCHALLENGErrgr)	rZ	mechanismZ
authobjectr�Zinitial_responseZresponserr��	challengerrrr�hs0
�

��z	SMTP.authcCs0|durdS|jdt�|j�d�|d���S)Nror9Zmd5)�user�hmacZHMAC�passwordrlZ	hexdigest�rr�rrr�
auth_cram_md5�s
�zSMTP.auth_cram_md5cCsd|j|jfS)Nz%s%s)r�r�r�rrr�
auth_plain�szSMTP.auth_plaincCs"|dus|jdkr|jS|jSdS)N�)rAr�r�r�rrr�
auth_login�szSMTP.auth_logincs�|��|�d�std��|jd���gd�}�fdd�|D�}|sNtd��|||_|_|D]v}d|���	dd	�}z4|j
|t||�|d
�\}}	|dvr�||	fWSWq`ty�}
z|
}WYd}
~
q`d}
~
00q`|�dS)Nr�z,SMTP AUTH extension not supported by server.)zCRAM-MD5ZPLAINZLOGINcsg|]}|�vr|�qSrr)r�r��Zadvertised_authlistrr�
<listcomp>�s�zSMTP.login.<locals>.<listcomp>z(No suitable authentication method found.Zauth_�-�_r�r�)
r�r�rr>r�rr�r�r�rrr��getattrr)rr�r�r�Zpreferred_authsZauthlistZ
authmethodZmethod_namerr�r�Zlast_exceptionrr�r�login�s.
�
�
z
SMTP.logincCs�|��|�d�std��|�d�\}}|dkr�ts<td��|durT|durTtd��|durl|durltd��|dus||dur�ddl}|�d	t	d
�|dur�t
j||d�}|j|j
|jd�|_
d|_d|_d|_i|_d|_n
t||��||fS)
N�starttlsz+STARTTLS extension not supported by server.ZSTARTTLSr:z&No SSL support included in this Python�4context and keyfile arguments are mutually exclusive�5context and certfile arguments are mutually exclusiver�Akeyfile and certfile are deprecated, use a custom context insteadr���certfile�keyfile�Zserver_hostname)r�r�rrK�	_have_ssl�RuntimeErrorrZ�warnings�warn�DeprecationWarning�ssl�_create_stdlib_context�wrap_socketrer<rQr�r�r>r�r)rr�r��contextr�Zreplyr�rrrr��s@
����
z
SMTP.starttlscCs^|��g}t|t�r$t|��d�}|jrZ|�d�rF|�dt|��|D]}|�|�qJ|�	||�\}}	|dkr�|dkr�|�
�n|��t||	|��i}
t|t�r�|g}|D]H}|�
||�\}}	|dkr�|dkr�||	f|
|<|dkr�|�
�t|
��q�t|
�t|�k�r|��t|
��|�|�\}}	|dk�rZ|dk�rH|�
�n|��t||	��|
S)Nr9�sizezsize=%dr�i��)r�rjrkr7rlr�r�r~r}r�rCr�rr�rr5r	)r�	from_addr�to_addrsr�mail_options�rcpt_optionsZ
esmtp_optsZoptionrr�Zsenderrsr�rrr�sendmail(sF@








z
SMTP.sendmailcCs�|��|�d�}|dur d}nt|�dkr2d}ntd��|dur||d|vrZ||dn
||d}tj�|g�dd}|dur�d	d
�||d||d||d
fD�}dd
�tj�|�D�}t�|�}	|	d=|	d=d}
zd�|g|���	d�Wn,t
�y&|�d��std��d}
Yn0t
���f}|
�rftjj||jjdd�d�}g|�d�d�R}ntj�|�}|j|	dd�|��}
Wd�n1�s�0Y|�|||
||�S)NzResent-Dater%rPzResent-z0message has more than one 'Resent-' header blockZSender�FromrcSsg|]}|dur|�qSrr)r��frrrr��s�z%SMTP.send_message.<locals>.<listcomp>�ToZBccZCccSsg|]}|d�qS)rPr)r��arrrr��r�z
Resent-BccFr9r�z�One or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)�utf8)�policyZSMTPUTF8z
BODY=8BITMIMEr)�linesep)r�Zget_allr}rZr'r(Zgetaddresses�copyrrl�UnicodeEncodeErrorr�r�io�BytesIO�	generatorZBytesGeneratorr�ZcloneZflatten�getvaluer�)rrr�r�r�r�ZresentZ
header_prefixZaddr_fieldsZmsg_copyZ
internationalZbytesmsg�gZflatmsgrrr�send_message�sV

�
�

�
�

�(�zSMTP.send_messagecCsTz4|j}d|_|r|��W|j}d|_|rP|��n|j}d|_|rN|��0dSr)rQrCre)rrQrerrrrC�s

�z
SMTP.closecCs.|�d�}d|_|_i|_d|_|��|S)N�quitF)rKr�r�r>r�rC)r�resrrrr��s
z	SMTP.quit)r\rN)r%)r%)r%)r%)r%)r)r)N)N)N)NNN)rr)NNrr)1rrrrNrerQr�r�r�r��	SMTP_PORTrcrE�_GLOBAL_DEFAULT_TIMEOUTr rIrMrOrXr[rBrnrtrfrKr�r8r�r�r�r�r�r�r�r5r�r�r�r�r�r�r�r�r�r�r�r�rCr�rrrrr�sd�
0
	

!

1



3


0
	

B
8�
h�
M
rcs<eZdZeZdddddejddfdd�Z�fdd�Z�Z	S)�SMTP_SSLr%rNc	
Cs�|dur|durtd��|dur0|dur0td��|dus@|durVddl}	|	�dtd�||_||_|durxtj||d�}||_t	�
||||||�dS)Nr�r�rr�r�r�)rZr�r�r�r�r�r�r�r�rr )
rrFrGrDr�r�r=r@r�r�rrrr s&���zSMTP_SSL.__init__cs@|jdkr|�d||f�t��|||�}|jj||jd�}|S)Nrr^r�)rNrX�superr[r�r�r<)rrFrGr=Z
new_socket��	__class__rrr[s
�zSMTP_SSL._get_socket)
rrr�
SMTP_SSL_PORTrcrEr�r r[�
__classcell__rrr�rr��s�
r�i�cs<eZdZdZdeddejf�fdd�	Zd
�fdd	�	Z�Z	S)�LMTPZlhlor%Ncst�j|||||d�dS)N)rDr@r=)r�r )rrFrGrDr@r=r�rrr <s�z
LMTP.__init__r\rcs�|ddkrt�j|||d�S|jdur6|js6td��zBt�tjtj�|_|jtjurd|j�	|j�d|_
|j�|�Wn@ty�|jdkr�|�
d|�|jr�|j��d|_�Yn0|��\}}|jdkr�|�
d|�||fS)Nr�/)r@rYz
connect fail:r^)r�rBr=rZrEZAF_UNIXZSOCK_STREAMrer�Z
settimeoutrQrbrNrXrCrf)rrFrGr@rrr�rrrBBs*


zLMTP.connect)r\rN)
rrrr��	LMTP_PORTrEr�r rBr�rrr�rr�,s
�r��__main__cCs(tj�|d�tj��tj����S)Nz: )rU�stdout�write�flush�stdinr{r*)�promptrrrras
rr�r��,zEnter message, end with ^D:r%zMessage length is %dr\rP)@rEr�r1Zemail.utilsr'Z
email.messageZemail.generatorr�r�r�rSrUZemail.base64mimerr��__all__r�r�r3r�r|r��compile�Ir�rbrrrrrrr	r
rrr
r.rr6r7r��ImportErrorr�rr�r~rr�rrZfromaddrr�ZtoaddrsrRrrr{r�r}ZserverrOr�r�rrrr�<module>,s�


	
</
4




?>