Your IP : 3.138.179.120


Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/smtplib.cpython-36.opt-2.pyc

3

��2aw��@sjddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Zddddddd	d
ddd
dgZdZdZdZdZdZejdej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�Z Gdd
�d
e�Z!Gdd�de�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,ej-d,�d-Z.Gd.d/�d/e+�Z/e0d0k�rfd1d2�Z1e1d3�Z2e1d4�j3d5�Z4e5d6�d7Z6x ej7j8�Z9e9�s Pe6e9Z6�qWe5d8e:e6��e+d9�Z;e;j<d:�e;j=e2e4e6�e;j>�dS);�N)�body_encode�
SMTPException�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/python36/lib64/python3.6/smtplib.pyrGsc@seZdZdS)�SMTPNotSupportedErrorN)rrrrrrrrJsrc@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)rN)rrrrrrrr�sc@seZdZdS)r	N)rrrrrrrr	�sc@seZdZdS)r
N)rrrrrrrr
�sc@seZdZdS)rN)rrrrrrrr�scCs>tjj|�\}}||fdkr6|j�jd�r.|Sd|Sd|S)N��<z<%s>)rr)�email�utils�	parseaddr�strip�
startswith)�
addrstring�displayname�addrrrrr�scCs$tjj|�\}}||fdkr |S|S)Nr)rr)r!r"r#)r&r'r(rrr�
_addr_only�sr)cCstjddtjdt|��S)Nz(?m)^\.z..z(?:\r\n|\n|\r(?!\n)))�re�sub�CRLF)�datarrrr
�scCstjdd|�S)Ns(?m)^\.s..)r*r+)Zbindatarrr�_quote_periods�sr.cCstjdt|�S)Nz(?:\r\n|\n|\r(?!\n)))r*r+r,)r-rrr�	_fix_eols�sr/FTc@s�eZdZdZdZdZdZdZdZe	Z
dddejdfdd�Z
dd�Zd	d
�Zdd�Zd
d�Zdd�ZdLdd�Zdd�ZdMdd�Zdd�ZdNdd�ZdOdd�ZdPdd�Zd d!�ZdQd"d#�Zd$d%�Zd&d'�Zd(d)�Zffd*d+�Zffd,d-�Z d.d/�Z!d0d1�Z"e"Z#d2d3�Z$d4d5�Z%d6d7�d8d9�Z&dRd:d;�Z'dSd<d=�Z(dTd>d?�Z)d6d7�d@dA�Z*dUdBdC�Z+fffdDdE�Z,ddfffdFdG�Z-dHdI�Z.dJdK�Z/dS)VrrN�ehlorc
Cs�||_||_i|_d|_||_|rL|j||�\}}|dkrL|j�t||��|dk	r\||_nPt	j
�}d|krt||_n8d}	yt	jt	j��}	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
gethostbynameZgethostnameZgaierror)
r�host�portr;r5r8rrZfqdnr(rrrr�s*
z
SMTP.__init__cCs|S)Nr)rrrr�	__enter__szSMTP.__enter__cGsNz>y$|jd�\}}|dkr$t||��Wntk
r:YnXWd|j�XdS)NZQUIT��)�docmdrrr:)rrr�messagerrr�__exit__s
z
SMTP.__exit__cCs
||_dS)N)�
debuglevel)rrDrrr�set_debuglevelszSMTP.set_debuglevelcGs@|jdkr,ttjj�j�f|�dtji�nt|dtji�dS)N��file)rD�print�datetimeZnowZtime�sys�stderr)rrrrr�_print_debug's
"zSMTP._print_debugcCs2|jdkr|jd||f|j�tj||f||j�S)Nrzconnect: to)rDrLr8r<�create_connection)rr=r>r5rrr�_get_socket-s
zSMTP._get_socket�	localhostcCs�|r
||_|r~|jd�|jd�kr~|jd�}|dkr~|d|�||dd�}}yt|�}Wntk
r|td��YnX|s�|j}|jdkr�|jd||f�|j	|||j
�|_d|_|j
�\}}|jdkr�|jdt|��||fS)N�:rrFznonnumeric portzconnect:)r8�find�rfind�int�
ValueError�OSError�default_portrDrLrNr5�sockrG�getreply�repr)rr=r>r8�irrrrrr95s(


zSMTP.connectcCs�|jdkr|jdt|��t|d�rx|jrxt|t�r@|j|j�}y|jj	|�Wq�t
k
rt|j�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|jdd�jdd�}td|����|j|�t���dS)Nr� �
�
z\nz\rz=command and arguments contain prohibited newline characters: )�replacerTr`r,)r�cmdrr_rrr�putcmdiszSMTP.putcmdcCsPg}|jdkr|jjd�|_�xy|jjtd�}Wn:tk
rn}z|j�tdt|���WYdd}~XnX|s�|j�td��|j	dkr�|j
dt|��t|�tkr�|j�t
dd��|j|d	d�jd
��|dd�}yt|�}Wntk
�rd}PYnX|dd	�dkr Pq Wd
j|�}|j	dk�rH|j
d||f�||fS)N�rbrFz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:i�zLine too long.�s 	
��-�
zreply: retcode (%s); Msg: %a���)rGrW�makefile�readline�_MAXLINErUr:rr]rDrLrY�lenr�appendr$rSrT�join)r�resp�line�erZerrcode�errmsgrrrrXvs>




z
SMTP.getreplycCs|j||�|j�S)N)rfrX)rrerrrrrA�sz
SMTP.docmdcCs,|jd|p|j�|j�\}}||_||fS)N�helo)rfr;rX�	helo_resp)r�namerrrrrrw�sz	SMTP.heloc
Cs2i|_|j|j|p|j�|j�\}}|dkrJt|�dkrJ|j�td��||_|dkr`||fSd|_	|jj
d�jd�}|d=x�|D]�}tj
|�}|r�|jjdd�d	|jd�d|jd<q�tj
d
|�}|r�|jd�j�}|j|jd�d�j�}	|dk�r|jj|d�d	|	|j|<q�|	|j|<q�W||fS)
NrFrzServer not connected�zlatin-1rc�authrraz((?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?�featurerl)r6rf�ehlo_msgr;rXrpr:r�	ehlo_resp�
does_esmtp�decode�split�
OLDSTYLE_AUTH�match�get�groupsr*�group�lower�string�endr$)
rryrrrs�eachZ
auth_match�mr|�paramsrrrr0�s2

&
z	SMTP.ehlocCs|j�|jkS)N)r�r6)r�optrrr�has_extn�sz
SMTP.has_extncCs|jd|�|j�dS)N�helprF)rfrX)rrrrrr��sz	SMTP.helpcCsd|_|jd�S)Nr1�rset)r7rA)rrrrr��sz	SMTP.rsetcCs&y|j�Wntk
r YnXdS)N)r�r)rrrr�_rset�sz
SMTP._rsetcCs
|jd�S)N�noop)rA)rrrrr�sz	SMTP.noopcCshd}|rH|jrHtdd�|D��r:|jd�r2d|_ntd��ddj|�}|jdd	t|�|f�|j�S)
Nrcss|]}|j�dkVqdS)�smtputf8N)r�)�.0�xrrr�	<genexpr>szSMTP.mail.<locals>.<genexpr>r�zutf-8z SMTPUTF8 not supported by serverra�mailz	FROM:%s%s)	r�anyr�r7rrrrfrrX)rr�options�
optionlistrrrr�	s	

z	SMTP.mailcCs<d}|r|jrddj|�}|jddt|�|f�|j�S)Nrra�rcptzTO:%s%s)rrrrfrrX)rZrecipr�r�rrrr�s

z	SMTP.rcptcCs�|jd�|j�\}}|jdkr0|jd||f�|dkrDt||��n|t|t�r\t|�jd�}t	|�}|dd�t
kr||t
}|dt
}|j|�|j�\}}|jdkr�|jd||f�||fSdS)	Nr-rzdata:ibr1��.���)rfrXrDrLrr\r]r/r^r.�bCRLFr`)rrr�repl�qrrrr-&s"





z	SMTP.datacCs|jdt|��|j�S)N�vrfy)rfr)rX)r�addressrrr�verifyCszSMTP.verifycCs|jdt|��|j�S)N�expn)rfr)rX)rr�rrrr�Jsz	SMTP.expncCsf|jdkrb|jdkrbd|j�dko.dknsb|j�\}}d|koRdknsbt||��dS)N��ri+)rxr~r0rwr
)rrrsrrr�ehlo_or_helo_if_neededQs
 zSMTP.ehlo_or_helo_if_neededT)�initial_response_okc	Cs�|j�}|r|�nd}|dk	rJt|jd�dd�}|jd|d|�\}}n|jd|�\}}|dkr�tj|�}t||�jd�dd�}|j|�\}}|d	kr�||fSt||��dS)
Nr1r)ZeolZAUTHraiN���)r�r�)�upper�
encode_base64r^rA�base64Zdecodebytesr)	rZ	mechanismZ
authobjectr�Zinitial_responseZresponserrs�	challengerrrr{bs
z	SMTP.authcCs0|dkrdS|jdtj|jjd�|d�j�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�|j�|jd�std��|jdj��dddg}�fdd�|D�}|sPtd��|||_|_xv|D]n}d	|j�j	d
d�}y.|j
|t||�|d�\}}	|dkr�||	fSWqdtk
r�}
z
|
}WYdd}
~
XqdXqdW|�dS)Nr{z,SMTP AUTH extension not supported by server.zCRAM-MD5ZPLAINZLOGINcsg|]}|�kr|�qSrr)r�r{)�advertised_authlistrr�
<listcomp>�szSMTP.login.<locals>.<listcomp>z(No suitable authentication method found.Zauth_�-�_)r�r��)r�r�)
r�r�rr6r�rr�r�r�rdr{�getattrr)rr�r�r�Zpreferred_authsZauthlistZ
authmethodZmethod_namerrsruZlast_exceptionr)r�r�login�s*



z
SMTP.logincCs�|j�|jd�std��|jd�\}}|dkr�ts<td��|dk	rT|dk	rTtd��|dk	rl|dk	rltd��|dk	s||dk	r�ddl}|jd	t	d
�|dkr�t
j||d�}|j|j
|jd�|_
d|_d|_d|_i|_d|_n
t||��||fS)
N�starttlsz+STARTTLS extension not supported by server.ZSTARTTLSr2z&No SSL support included in this Pythonz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadr�)�certfile�keyfile)�server_hostname)r�r�rrA�	_have_ssl�RuntimeErrorrT�warnings�warn�DeprecationWarning�ssl�_create_stdlib_context�wrap_socketrWr4rGrxr~r6rr)rr�r��contextrsZreplyr�rrrr��s8

z
SMTP.starttlscCsf|j�g}t|t�r$t|�jd�}|jr^|jd�rF|jdt|��x|D]}|j|�qLW|j	||�\}}	|dkr�|dkr�|j
�n|j�t||	|��i}
t|t�r�|g}xP|D]H}|j
||�\}}	|dkr�|dkr�||	f|
|<|dkr�|j
�t|
��q�Wt|
�t|�k�r$|j�t|
��|j|�\}}	|dk�rb|dk�rP|j
�n|j�t||	��|
S)Nr1�sizezsize=%drzi��)r�r\r]r/r^rr�rqrpr�r:r�rr�rr-r)r�	from_addr�to_addrsr�mail_options�rcpt_optionsZ
esmtp_opts�optionrrsZsenderrsr�rrr�sendmailsF@









z
SMTP.sendmailcCs�|j�|jd�}|dkr d}nt|�dkr2d}ntd��|dkr||d|krZ||dn
||d}tjj|g�dd}|dkr�d	d
�||d||d||d
fD�}dd
�tjj|�D�}tj|�}	|	d=|	d=d}
ydj|f|��j	d�Wn.t
k
�r(|jd��s td��d}
YnXt
j��R}|
�r^tjj||jjdd�d�}|d�}ntjj|�}|j|	dd�|j�}
WdQRX|j|||
||�S)NzResent-DaterrFzResent-z0message has more than one 'Resent-' header blockZSender�FromrcSsg|]}|dk	r|�qS)Nr)r��frrrr��sz%SMTP.send_message.<locals>.<listcomp>�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_allrprTr!r"Zgetaddresses�copyrrr^�UnicodeEncodeErrorr�r�io�BytesIO�	generatorZBytesGeneratorr�ZcloneZflatten�getvaluer�)rrr�r�r�r�ZresentZ
header_prefixZaddr_fieldsZmsg_copy�
internationalZbytesmsg�gZflatmsgrrr�send_message�sJ





zSMTP.send_messagecCs<z|j}d|_|r|j�Wd|j}d|_|r6|j�XdS)N)rGr:rW)rrGrWrrrr:�sz
SMTP.closecCs.|jd�}d|_|_i|_d|_|j�|S)N�quitF)rAr~rxr6rr:)r�resrrrr��s
z	SMTP.quit)rOrN)r)r)r)r)r)N)N)N)NNN)0rrrrDrGrxr}r~r�	SMTP_PORTrVr<�_GLOBAL_DEFAULT_TIMEOUTrr?rCrErLrNr9r`rfrXrArwr0r�r�r�r�r�r�r�r-r�r�r�r�r{r�r�r�r�r�r�r�r:r�rrrrr�s\-
	
"

1



3
'
	

B
8gL
c@s4eZdZeZdddddejddfdd�Zdd�ZdS)�SMTP_SSLrrNc	
Cs�|dk	r|dk	rtd��|dk	r0|dk	r0td��|dk	s@|dk	rVddl}	|	jdtd�||_||_|dkrxtj||d�}||_t	j
||||||�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|jd||f�tj||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|||||d�dS)N)r;r8)rr)rr=r>r;r8rrrr.sz
LMTP.__init__rOrcCs�|ddkrtj||||d�Sy(tjtjtj�|_d|_|jj|�WnBtk
r�|jdkrl|j	d|�|jr||jj
�d|_�YnX|j�\}}|jdkr�|j	d|�||fS)Nr�/)r8z
connect fail:zconnect:)rr9r<ZAF_UNIXZSOCK_STREAMrWrGrUrDrLr:rX)rr=r>r8rrrrrr94s"


zLMTP.connect)rOrN)rrrr}�	LMTP_PORTrr9rrrrr�sr��__main__cCs(tjj|d�tjj�tjj�j�S)Nz: )rJ�stdout�write�flush�stdinrnr$)�promptrrrr�Ns
r�r�r��,zEnter message, end with ^D:rzMessage length is %drOrF)?r<r�r*Zemail.utilsr!Z
email.messageZemail.generatorr�r�r�rIrJZemail.base64mimerr��__all__r�r�r,r�ro�compile�Ir�rUrrrrrrrr	r
rrr)r
r.r/r��ImportErrorr�rr�rqr�r�rr�Zfromaddrr�ZtoaddrsrHrr�rnrtrpZserverrEr�r�rrrr�<module>,s�



	
.0
/




?>