Hacked By AnonymousFox

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

a

R�fj��@sZdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZgd�ZdZdZdZdZd	Zd
Ze�dej�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$d d!�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/�d0Z0Gd1d2�d2e-�Z1e2d3k�rVd4d5�Z3e3d6�Z4e3d7��5d8�Z6e7d9�d:Z8ej9�:�Z;e;�s�qe8e;Z8�q�e7d;e<e8��e-d<�Z=e=�>d=�e=�?e4e6e8�e=�@�dS)>aSMTP/ESMTP client class.

This should follow RFC 821 (SMTP), RFC 1869 (ESMTP), RFC 2554 (SMTP
Authentication) and RFC 2487 (Secure SMTP over TLS).

Notes:

Please remember, when doing ESMTP, that the names of the SMTP service
extensions are NOT the same thing as the option keywords for the RCPT
and MAIL commands!

Example:

  >>> import smtplib
  >>> s=smtplib.SMTP("localhost")
  >>> print(s.help())
  This is Sendmail version 8.8.4
  Topics:
      HELO    EHLO    MAIL    RCPT    DATA
      RSET    NOOP    QUIT    HELP    VRFY
      EXPN    VERB    ETRN    DSN
  For more info use "HELP <topic>".
  To report bugs in the implementation send email to
      sendmail-bugs@sendmail.org.
  For local information send email to Postmaster at your site.
  End of HELP info
  >>> s.putcmd("vrfy","someone@here")
  >>> s.getreply()
  (250, "Somebody OverHere <somebody@here.my.org>")
  >>> s.quit()
�N)�body_encode)
�
SMTPException�SMTPNotSupportedError�SMTPServerDisconnected�SMTPResponseException�SMTPSenderRefused�SMTPRecipientsRefused�
SMTPDataError�SMTPConnectError�
SMTPHeloError�SMTPAuthenticationError�	quoteaddr�	quotedata�SMTP�i��
s
i �z	auth=(.*)c@seZdZdZdS)rz4Base class for all exceptions raised by this module.N��__name__�
__module__�__qualname__�__doc__�rr�,/opt/alt/python39/lib64/python3.9/smtplib.pyrHsrc@seZdZdZdS)rz�The command or option is not supported by the SMTP server.

    This exception is raised when an attempt is made to run a command or a
    command with an option which is not supported by the server.
    NrrrrrrKsrc@seZdZdZdS)rz�Not connected to any SMTP server.

    This exception is raised when the server unexpectedly disconnects,
    or when an attempt is made to use the SMTP instance before
    connecting it to a server.
    NrrrrrrRsrc@seZdZdZdd�ZdS)ra2Base class for all exceptions that include an SMTP error code.

    These exceptions are generated in some instances when the SMTP
    server returns an error code.  The error code is stored in the
    `smtp_code' attribute of the error, and the `smtp_error' attribute
    is set to the error message.
    cCs||_||_||f|_dS�N)�	smtp_code�
smtp_error�args)�self�code�msgrrr�__init__cszSMTPResponseException.__init__N�rrrrr!rrrrrZsrc@seZdZdZdd�ZdS)rz�Sender address refused.

    In addition to the attributes set by on all SMTPResponseException
    exceptions, this sets `sender' to the string that the SMTP refused.
    cCs"||_||_||_|||f|_dSr)rr�senderr)rrr r#rrrr!oszSMTPSenderRefused.__init__Nr"rrrrrhsrc@seZdZdZdd�ZdS)rz�All recipient addresses refused.

    The errors for each recipient are accessible through the attribute
    'recipients', which is a dictionary of exactly the same sort as
    SMTP.sendmail() returns.
    cCs||_|f|_dSr)�
recipientsr)rr$rrrr!}szSMTPRecipientsRefused.__init__Nr"rrrrrusrc@seZdZdZdS)r	z'The SMTP server didn't accept the data.Nrrrrrr	�sr	c@seZdZdZdS)r
z&Error during connection establishment.Nrrrrrr
�sr
c@seZdZdZdS)rz"The server refused our HELO reply.Nrrrrrr�src@seZdZdZdS)rzvAuthentication error.

    Most probably the server didn't accept the username/password
    combination provided.
    Nrrrrrr�srcCs>tj�|�\}}||fdkr6|���d�r.|Sd|Sd|S)z�Quote a subset of the email addresses defined by RFC 821.

    Should be able to handle anything email.utils.parseaddr can handle.
    ��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)z�Quote data for email.

    Double leading '.', and change Unix newline '\n', or Mac '\r' into
    Internet CRLF end-of-line.
    z(?m)^\.z..�(?:\r\n|\n|\r(?!\n))��re�sub�CRLF��datarrrr�s�rcCst�dd|�S)Ns(?m)^\.s..)r2r3)Zbindatarrr�_quote_periods�sr7cCst�dt|�S)Nr0r1r5rrr�	_fix_eols�sr8FTc@szeZdZdZdZdZdZdZdZdZ	dZ
eZddde
jdfdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZdNdd�Zdd�ZdOdd�Zdd�ZdPdd�ZdQdd�ZdRdd �Zd!d"�ZdSd#d$�Zd%d&�Zd'd(�Zd)d*�Z dTd,d-�Z!dUd.d/�Z"d0d1�Z#d2d3�Z$e$Z%d4d5�Z&d6d7�Z'd8d9�d:d;�Z(dVd<d=�Z)dWd>d?�Z*dXd@dA�Z+d8d9�dBdC�Z,dYdDdE�Z-dZdFdG�Z.d[dHdI�Z/dJdK�Z0dLdM�Z1dS)\ra�This class manages a connection to an SMTP or ESMTP server.
    SMTP Objects:
        SMTP objects have the following attributes:
            helo_resp
                This is the message given by the server in response to the
                most recent HELO command.

            ehlo_resp
                This is the message given by the server in response to the
                most recent EHLO command. This is usually multiline.

            does_esmtp
                This is a True value _after you do an EHLO command_, if the
                server supports ESMTP.

            esmtp_features
                This is a dictionary, which, if the server supports ESMTP,
                will _after you do an EHLO command_, contain the names of the
                SMTP service extensions this server supports, and their
                parameters (if any).

                Note, all extension names are mapped to lower case in the
                dictionary.

        See each method's docstrings for details.  In general, there is a
        method of the same name to perform each SMTP command.  There is also a
        method called 'sendmail' that will do an entire mail transaction.
        rN�ehlor&c
Cs�||_||_i|_d|_||_d|_|rR|�||�\}}|dkrR|��t||��|durb||_	nNt
��}d|vrz||_	n6d}	zt
�t
�
��}	Wnt
jy�Yn0d|	|_	dS)aInitialize a new instance.

        If specified, `host` is the name of the remote host to which to
        connect.  If specified, `port` specifies the port to which to connect.
        By default, smtplib.SMTP_PORT is used.  If a host is specified the
        connect method is called, and if it returns anything other than a
        success code an SMTPConnectError is raised.  If specified,
        `local_hostname` is used as the FQDN of the local host in the HELO/EHLO
        command.  Otherwise, the local hostname is found using
        socket.getfqdn(). The `source_address` parameter takes a 2-tuple (host,
        port) for the socket to bind to as its source address before
        connecting. If the host is '' and port is 0, the OS default behavior
        will be used.

        �asciir��N�.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�portrEr>rArr Zfqdnr.rrrr!�s,
z
SMTP.__init__cCs|Srr�rrrr�	__enter__szSMTP.__enter__cGsTzDz$|�d�\}}|dkr$t||��Wnty8Yn0W|��n
|��0dS)NZQUIT��)�docmdrrrD)rrr�messagerrr�__exit__sz
SMTP.__exit__cCs
||_dS)z�Set the debug output level.

        A non-false value results in debug messages for connection and for all
        messages sent to and received from the server.

        N)�
debuglevel)rrOrrr�set_debuglevel"szSMTP.set_debuglevelcGsB|jdkr.ttj����g|�Rdtji�nt|dtji�dS)N��file)rO�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)�
ValueErrorrOrYrArFZcreate_connection)rrGrHr>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)apConnect to a host on a given port.

        If the hostname ends with a colon (`:') followed by a number, and
        there is no port specified, that suffix will be stripped off and the
        number interpreted as the port number to use.

        Note: This method is automatically invoked by __init__, if a host is
        specified during instantiation.

        �:rNrQznonnumeric portzsmtplib.connect�connect:)rA�find�rfind�intr[�OSError�default_portrV�auditr\r>�sockrR�getreplyrOrY�repr)rrGrHrA�irr rrrrC;s&

zSMTP.connectcCs�|jdkr|�dt|��|jrzt|t�r6|�|j�}t�	d||�z|j�
|�Wq�tyv|��t
d��Yq�0nt
d��dS)zSend `s' to the server.rzsend:zsmtplib.send�Server not connectedzplease run connect() firstN)rOrYrhrf�
isinstance�str�encoder@rVreZsendallrcrDr)r�srrr�send\s

z	SMTP.sendcCsd|dkr|}n|�d|��}d|vs,d|vrN|�dd��dd�}td|����|�|�t���dS)	zSend a command to the server.r&� �
�
z\nz\rz=command and arguments contain prohibited newline characters: N)�replacer[ror4)r�cmdrrnrrr�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|dd
�dkr�q qd�|�}|j	dk�rH|�
d||f�||fS)a�Get a reply from the server.

        Returns a tuple consisting of:

          - server response code (e.g. '250', or such, if all goes well)
            Note: returns -1 if it can't read response code.

          - server response string corresponding to response code (multiline
            responses are converted to a single, multiline string).

        Raises SMTPServerDisconnected if end-of-file is reached.
        N�rbrQz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:i�zLine too long.�s 	
�����-�
zreply: retcode (%s); Msg: %a)rRrfZmakefile�readline�_MAXLINErcrDrrlrOrYrh�lenr�appendr+rbr[�join)r�resp�line�erZerrcode�errmsgrrrrg|s>

�


z
SMTP.getreplycCs|�||�|��S)z-Send a command, and return its response code.�rurg)rrtrrrrrL�sz
SMTP.docmdcCs,|�d|p|j�|��\}}||_||fS)zwSMTP 'helo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        �helo)rurErg�	helo_resp)r�namerr rrrr��sz	SMTP.heloc
CsHi|_|�|j|p|j�|��\}}|dkrJt|�dkrJ|��td��||_|dkr`||fSd|_	t
|jt�s�Jt|j���|j�
d��d�}|d=|D]�}t�|�}|r�|j�dd	�d
|�d�d|jd<q�t�d|�}|r�|�d���}|j|�d�d
���}	|dk�r4|j�|d	�d
|	|j|<q�|	|j|<q�||fS)zx SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        ryrrj�rQzlatin-1rr�authr&rpz((?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?�featureN)r?ru�ehlo_msgrErgr~rDr�	ehlo_resp�
does_esmtprk�bytesrh�decode�split�
OLDSTYLE_AUTH�match�get�groupsr2�group�lower�string�endr+)
rr�rr r��eachZ
auth_match�mr��paramsrrrr9�sD
��

��z	SMTP.ehlocCs|��|jvS)z7Does the server support a given SMTP service extension?)r�r?)r�optrrr�has_extn�sz
SMTP.has_extncCs|�d|�|��dS)z;SMTP 'help' command.
        Returns help text from server.�helprQr�rXrrrr��sz	SMTP.helpcCsd|_|�d�S)z&SMTP 'rset' command -- resets session.r:�rset)r@rLrIrrrr��sz	SMTP.rsetcCs$z|��WntyYn0dS)aInternal 'rset' command which ignores any SMTPServerDisconnected error.

        Used internally in the library, since the server disconnected error
        should appear to the application when the *next* command is issued, if
        we are doing an internal "safety" reset.
        N)r�rrIrrr�_rset�sz
SMTP._rsetcCs
|�d�S)z-SMTP 'noop' command -- doesn't do anything :>�noop)rLrIrrrr�sz	SMTP.nooprcCshd}|rH|jrHtdd�|D��r:|�d�r2d|_ntd��dd�|�}|�dd	t|�|f�|��S)
a8SMTP 'mail' command -- begins mail xfer session.

        This method may raise the following exceptions:

         SMTPNotSupportedError  The options parameter includes 'SMTPUTF8'
                                but the SMTPUTF8 extension is not supported by
                                the server.
        r&css|]}|��dkVqdS)�smtputf8N)r�)�.0�xrrr�	<genexpr>�zSMTP.mail.<locals>.<genexpr>r�zutf-8z SMTPUTF8 not supported by serverrp�mailz	FROM:%s%s)	r��anyr�r@rr�rur
rg)rr#�options�
optionlistrrrr�s	

�z	SMTP.mailcCs<d}|r|jrdd�|�}|�ddt|�|f�|��S)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r&rp�rcptzTO:%s%s)r�r�rur
rg)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)	a�SMTP 'DATA' command -- sends message data to server.

        Automatically quotes lines beginning with a period per rfc821.
        Raises SMTPDataError if there is an unexpected reply to the
        DATA command; the return value from this method is the final
        response code received when the all data is sent.  If msg
        is a string, lone '\r' and '\n' characters are converted to
        '\r\n' characters.  If msg is bytes, it is transmitted as is.
        r6rzdata:ibr:���N�.)rurgrOrYr	rkrlr8rmr7�bCRLFro)rr r�repl�qrrrr6,s"





z	SMTP.datacCs|�dt|��|��S)z5SMTP 'verify' command -- checks for address validity.�vrfy�rur/rg�rZaddressrrr�verifyIszSMTP.verifycCs|�dt|��|��S)z.SMTP 'expn' command -- expands a mailing list.�expnr�r�rrrr�Psz	SMTP.expncCsb|jdur^|jdur^d|��dkr0dks^n|��\}}d|krRdks^nt||��dS)abCall self.ehlo() and/or self.helo() if needed.

        If there has been no previous EHLO or HELO command this session, this
        method tries ESMTP EHLO first.

        This method may raise the following exceptions:

         SMTPHeloError            The server didn't reply properly to
                                  the helo greeting.
        N��ri+)r�r�r9r�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|_|d	kr�|jd7_t�|�}t||��d�dd�}|�|�\}}|jtkrftd
t	||f���qf|dvr�||fSt
||��dS)a�Authentication command - requires response processing.

        'mechanism' specifies which authentication mechanism is to
        be used - the valid values are those listed in the 'auth'
        element of 'esmtp_features'.

        'authobject' must be a callable object taking a single argument:

                data = authobject(challenge)

        It will be called to process the server's challenge response; the
        challenge argument it is passed will be a bytes.  It should return
        an ASCII string that will be base64 encoded and sent to the server.

        Keyword arguments:
            - initial_response_ok: Allow sending the RFC 4954 initial-response
              to the AUTH command, if the authentication methods supports it.
        Nr:r&)ZeolZAUTHrprQriNz4Server AUTH mechanism infinite loop. Last response: ���i�)�upper�
encode_base64rmrLrB�base64Zdecodebytes�
_MAXCHALLENGErrhr)	rZ	mechanismZ
authobjectr�Zinitial_responseZresponserr��	challengerrrr�hs0
�

��z	SMTP.authcCs0|durdS|jdt�|j�d�|d���S)zh Authobject to use with CRAM-MD5 authentication. Requires self.user
        and self.password to be set.Nrpr:Zmd5)�user�hmacZHMAC�passwordrmZ	hexdigest�rr�rrr�
auth_cram_md5�s
�zSMTP.auth_cram_md5cCsd|j|jfS)ze Authobject to use with PLAIN authentication. Requires self.user and
        self.password to be set.z%s%s)r�r�r�rrr�
auth_plain�szSMTP.auth_plaincCs"|dus|jdkr|jS|jSdS)ze Authobject to use with LOGIN authentication. Requires self.user and
        self.password to be set.N�)rBr�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`|�dS)
awLog in on an SMTP server that requires authentication.

        The arguments are:
            - user:         The user name to authenticate with.
            - password:     The password for the authentication.

        Keyword arguments:
            - initial_response_ok: Allow sending the RFC 4954 initial-response
              to the AUTH command, if the authentication methods supports it.

        If there has been no previous EHLO or HELO command this session, this
        method tries ESMTP EHLO first.

        This method will return normally if the authentication was successful.

        This method may raise the following exceptions:

         SMTPHeloError            The server didn't reply properly to
                                  the helo greeting.
         SMTPAuthenticationError  The server didn't accept the username/
                                  password combination.
         SMTPNotSupportedError    The AUTH command is not supported by the
                                  server.
         SMTPException            No suitable authentication method was
                                  found.
        r�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�N)
r�r�rr?r�rr�r�r�rsr��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�d	dl}|�d
t	d�|dur�t
j||d�}|j|j
|jd
�|_
d|_d|_d|_i|_d	|_n
t||��||fS)a�Puts the connection to the SMTP server into TLS mode.

        If there has been no previous EHLO or HELO command this session, this
        method tries ESMTP EHLO first.

        If the server supports TLS, this will encrypt the rest of the SMTP
        session. If you provide the keyfile and certfile parameters,
        the identity of the SMTP server and client can be checked. This,
        however, depends on whether the socket module really checks the
        certificates.

        This method may raise the following exceptions:

         SMTPHeloError            The server didn't reply properly to
                                  the helo greeting.
        �starttlsz+STARTTLS extension not supported by server.ZSTARTTLSr;z&No SSL support included in this PythonN�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�rrL�	_have_ssl�RuntimeErrorr[�warnings�warn�DeprecationWarning�ssl�_create_stdlib_context�wrap_socketrfr=rRr�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)a|This command performs an entire mail transaction.

        The arguments are:
            - from_addr    : The address sending this mail.
            - to_addrs     : A list of addresses to send this mail to.  A bare
                             string will be treated as a list with 1 address.
            - msg          : The message to send.
            - mail_options : List of ESMTP options (such as 8bitmime) for the
                             mail command.
            - rcpt_options : List of ESMTP options (such as DSN commands) for
                             all the rcpt commands.

        msg may be a string containing characters in the ASCII range, or a byte
        string.  A string is encoded to bytes using the ascii codec, and lone
        \r and \n characters are converted to \r\n characters.

        If there has been no previous EHLO or HELO command this session, this
        method tries ESMTP EHLO first.  If the server does ESMTP, message size
        and each of the specified options will be passed to it.  If EHLO
        fails, HELO will be tried and ESMTP options suppressed.

        This method will return normally if the mail is accepted for at least
        one recipient.  It returns a dictionary, with one entry for each
        recipient that was refused.  Each entry contains a tuple of the SMTP
        error code and the accompanying error message sent by the server.

        This method may raise the following exceptions:

         SMTPHeloError          The server didn't reply properly to
                                the helo greeting.
         SMTPRecipientsRefused  The server rejected ALL recipients
                                (no mail was sent).
         SMTPSenderRefused      The server didn't accept the from_addr.
         SMTPDataError          The server replied with an unexpected
                                error code (other than a refusal of
                                a recipient).
         SMTPNotSupportedError  The mail_options parameter includes 'SMTPUTF8'
                                but the SMTPUTF8 extension is not supported by
                                the server.

        Note: the connection will be open even after an exception is raised.

        Example:

         >>> import smtplib
         >>> s=smtplib.SMTP("localhost")
         >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
         >>> msg = '''\
         ... From: Me@my.org
         ... Subject: testin'...
         ...
         ... This is a test '''
         >>> s.sendmail("me@my.org",tolist,msg)
         { "three@three.org" : ( 550 ,"User unknown" ) }
         >>> s.quit()

        In the above example, the message was accepted for delivery to three
        of the four addresses, and one was rejected, with the error code
        550.  If all addresses are accepted, then the method will return an
        empty dictionary.

        r:�sizezsize=%dr�i��)r�rkrlr8rmr�r�rr~r�rDr�rr�rr6r	)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�d	d}|dur�d
d�||d||d
||dfD�}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)a~Converts message to a bytestring and passes it to sendmail.

        The arguments are as for sendmail, except that msg is an
        email.message.Message object.  If from_addr is None or to_addrs is
        None, these arguments are taken from the headers of the Message as
        described in RFC 2822 (a ValueError is raised if there is more than
        one set of 'Resent-' headers).  Regardless of the values of from_addr and
        to_addr, any Bcc field (or Resent-Bcc field, when the Message is a
        resent) of the Message object won't be transmitted.  The Message
        object is then serialized using email.generator.BytesGenerator and
        sendmail is called to transmit the message.  If the sender or any of
        the recipient addresses contain non-ASCII and the server advertises the
        SMTPUTF8 capability, the policy is cloned with utf8 set to True for the
        serialization, and SMTPUTF8 and BODY=8BITMIME are asserted on the send.
        If the server does not support SMTPUTF8, an SMTPNotSupported error is
        raised.  Otherwise the generator is called without modifying the
        policy.

        zResent-DateNr&rQzResent-z0message has more than one 'Resent-' header blockZSender�FromrcSsg|]}|dur|�qSrr)r��frrrr��s�z%SMTP.send_message.<locals>.<listcomp>�ToZBccZCccSsg|]}|d�qS)rQr)r��arrrr��r�z
Resent-BccFr:r�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~r[r(r)Zgetaddresses�copyr�rm�UnicodeEncodeErrorr�r�io�BytesIO�	generatorZBytesGeneratorr�ZcloneZflatten�getvaluer�)rr r�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|��0dS)z(Close the connection to the SMTP server.N)rRrDrf)rrRrfrrrrD�s

�z
SMTP.closecCs.|�d�}d|_|_i|_d|_|��|S)zTerminate the SMTP session.�quitNF)rLr�r�r?r�rD)r�resrrrr��s
z	SMTP.quit)r]rN)r&)r&)r&)r&)r&)r)r)N)N)N)NNN)rr)NNrr)2rrrrrOrfrRr�r�r�r��	SMTP_PORTrdrF�_GLOBAL_DEFAULT_TIMEOUTr!rJrNrPrYr\rCrorurgrLr�r9r�r�r�r�r�r�r�r6r�r�r�r�r�r�r�r�r�r�r�r�rDr�rrrrr�sf�
0
	

!

1



3


0
	

B
8�
h�
M
rcs@eZdZdZeZdddddejddfdd�Z�fdd�Z	�Z
S)	�SMTP_SSLa� This is a subclass derived from SMTP that connects over an SSL
        encrypted socket (to use this class you need a socket module that was
        compiled with SSL support). If host is not specified, '' (the local
        host) is used. If port is omitted, the standard SMTP-over-SSL port
        (465) is used.  local_hostname and source_address have the same meaning
        as they do in the SMTP class.  keyfile and certfile are also optional -
        they can contain a PEM formatted private key and certificate chain file
        for the SSL connection. context also optional, can contain a
        SSLContext, and is an alternative to keyfile and certfile; If it is
        specified both keyfile and certfile must be None.

        r&rNc	
Cs�|dur|durtd��|dur0|dur0td��|dus@|durVddl}	|	�dtd�||_||_|durxtj||d�}||_t	�
||||||�dS)Nr�r�rr�r�r�)r[r�r�r�r�r�r�r�r�rr!)
rrGrHrEr�r�r>rAr�r�rrrr!s&���zSMTP_SSL.__init__cs@|jdkr|�d||f�t��|||�}|jj||jd�}|S)Nrr_r�)rOrY�superr\r�r�r=)rrGrHr>Z
new_socket��	__class__rrr\s
�zSMTP_SSL._get_socket)rrrr�
SMTP_SSL_PORTrdrFr�r!r\�
__classcell__rrr�rr��s
�
r�i�cs@eZdZdZdZdeddejf�fdd�	Zd�fd	d
�	Z	�Z
S)�LMTPa�LMTP - Local Mail Transfer Protocol

    The LMTP protocol, which is very similar to ESMTP, is heavily based
    on the standard SMTP client. It's common to use Unix sockets for
    LMTP, so our connect() method must support that as well as a regular
    host:port server.  local_hostname and source_address have the same
    meaning as they do in the SMTP class.  To specify a Unix socket,
    you must use an absolute path as the host, starting with a '/'.

    Authentication is supported, using the regular SMTP mechanism. When
    using a Unix socket, LMTP generally don't support or require any
    authentication, but your mileage might vary.Zlhlor&Ncst�j|||||d�dS)zInitialize a new instance.)rErAr>N)r�r!)rrGrHrErAr>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)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.r�/)rANrZz
connect fail:r_)r�rCr>r[rFZAF_UNIXZSOCK_STREAMrfr�Z
settimeoutrRrcrOrYrDrg)rrGrHrArr r�rrrCBs*


zLMTP.connect)r]rN)rrrrr��	LMTP_PORTrFr�r!rCrrrr�rr,s
�r�__main__cCs(tj�|d�tj��tj����S)Nz: )rV�stdout�write�flush�stdinr|r+)�promptrrrr	as
r	r�r��,zEnter message, end with ^D:r&zMessage length is %dr]rQ)ArrFr�r2Zemail.utilsr(Z
email.messageZemail.generatorr�r�r�rTrVZemail.base64mimerr��__all__r�r�r4r�r}r��compile�Ir�rcrrrrrrr	r
rrr
r/rr7r8r��ImportErrorr�rr�rrrrr	Zfromaddrr�ZtoaddrsrSr rr|r�r~ZserverrPr�r�rrrr�<module>s�)


	
</
4




Hacked By AnonymousFox1.0, Coded By AnonymousFox