%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/__pycache__/smtplib.cpython-312.pyc

�

���f�����dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZgd�ZdZdZdZdZd	Zd
Zej.dej0�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�de�Z!Gd�de�Z"Gd�de�Z#Gd�de�Z$d �Z%d!�Z&d"�Z'd#�Z(d$�Z)	ddl*Z*d%Z+Gd'�d(�Z-e+rGd)�d*e-�Z.ej_d*�d+Z0Gd,�d-e-�Z1e2d.k(r�d/�Z3e3d0�Z4e3d1�jkd2�Z6e7d3�d4Z8ejrju�xZ;r"e8e;zZ8ejrju�xZ;r�"e7d5e<e8�z�e-d6�Z=e=j}d7�e=je4e6e8�e=j��yy#e,$rd&Z+Y��wxYw)8aSMTP/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��eZdZdZy)rz4Base class for all exceptions raised by this module.N��__name__�
__module__�__qualname__�__doc__���/usr/lib/python3.12/smtplib.pyrrHs��>rrc��eZdZdZy)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.
    NrrrrrrK���rrc��eZdZdZy)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.
    NrrrrrrRs��rrc��eZdZdZd�Zy)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.
    c�2�||_||_||f|_y�N)�	smtp_code�
smtp_error�args)�self�code�msgs   r�__init__zSMTPResponseException.__init__cs���������3�K��	rN�rrrrr)rrrrrZs��� rrc��eZdZdZd�Zy)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.
    c�B�||_||_||_|||f|_yr")r#r$�senderr%)r&r'r(r-s    rr)zSMTPSenderRefused.__init__os%������������3��'��	rNr*rrrrrhs���(rrc��eZdZdZd�Zy)r	z�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.
    c�"�||_|f|_yr")�
recipientsr%)r&r0s  rr)zSMTPRecipientsRefused.__init__}s��$����M��	rNr*rrrr	r	us���"rr	c��eZdZdZy)r
z'The SMTP server didn't accept the data.Nrrrrr
r
�s��1rr
c��eZdZdZy)rz&Error during connection establishment.Nrrrrrr�s��0rrc��eZdZdZy)rz"The server refused our HELO reply.Nrrrrrr�s��,rrc��eZdZdZy)r
zvAuthentication error.

    Most probably the server didn't accept the username/password
    combination provided.
    Nrrrrr
r
�rrr
c��tjj|�\}}||fdk(r&|j�j	d�r|Sd|zSd|zS)z�Quote a subset of the email addresses defined by RFC 821.

    Should be able to handle anything email.utils.parseaddr can handle.
    ��r7�<z<%s>)�email�utils�	parseaddr�strip�
startswith��
addrstring�displayname�addrs   rrr�s\��
���-�-�j�9��K���T��h�&�����(�(��-����
�"�"��D�=�rc�\�tjj|�\}}||fdk(r|S|S)Nr6)r9r:r;r>s   r�
_addr_onlyrC�s3�����-�-�j�9��K���T��h�&����Krc	�b�tjddtjdt|��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��datas rrr�s*���6�6�*�d�
���&��d�3�5�5rc�0�tjdd|�S)Ns(?m)^\.s..)rGrH)�bindatas r�_quote_periodsrN�s��
�6�6�+�u�g�.�.rc�8�tjdt|�S)NrErFrJs r�	_fix_eolsrP�s���F�F�*�D�$�7�7rTFc�T�eZdZdZdZdZdZdZdZdZ	dZ
eZddde
jdfd�Zd�Zd	�Zd
�Zd�Zd�Zd,d
�Zd�Zd-d�Zd�Zd-d�Zd-d�Zd-d�Zd�Zd-d�Zd�Zd�Zd�Z d.d�Z!d.d�Z"d�Z#d�Z$e$Z%d�Z&d�Z'dd �d!�Z(d/d"�Z)d/d#�Z*d/d$�Z+dd �d%�Z,dd&�d'�Z-		d0d(�Z.		d1d)�Z/d*�Z0d+�Z1y)2ra�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�ehloFr7c��||_||_i|_d|_||_d|_|r6|j
||�\}}|dk7r|j�t||��|�||_	ytj�}d|vr||_	yd}		tjtj��}	d|	z|_	y#tj$rY� wxYw)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�socket�getfqdn�
gethostbyname�gethostname�gaierror)
r&�host�portr_rXr[r'r(�fqdnrAs
          rr)z
SMTP.__init__�s���$��
���� ��� '���,���%&��"���,�,�t�T�2�K�T�3��s�{��
�
��&�t�S�1�1��%�"0�D��
�>�>�#�D��d�{�&*��#�#���!�/�/��0B�0B�0D�E�D�'-�t�m��#��������s�'C�C�Cc��|Sr"r�r&s r�	__enter__zSMTP.__enter__s���rc��	|jd�\}}|dk7rt||��	|j�y#t$rY�wxYw#|j�wxYw)N�QUIT��)�docmdrrr^)r&r%r'�messages    r�__exit__z
SMTP.__exit__s]��	� �J�J�v�.�M�D�'��s�{�+�D�'�:�:��

�J�J�L��&�	��	��
�J�J�L�s&�%9�A�	A�A�A�A�Ac��||_y)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)r&rrs  r�set_debuglevelzSMTP.set_debuglevel"s��%��rc���|jdkDrHttjj�j	�g|��dt
ji�yt|dt
ji�y)N��file)rr�print�datetime�now�time�sys�stderr�r&r%s  r�_print_debugzSMTP._print_debug+sM���?�?�Q���(�#�#�'�'�)�.�.�0�I�4�I�c�j�j�I��4�)�c�j�j�)rc���|�
|std��|jdkDr|jd||f|j�t	j
||f||j�S)N�0Non-blocking socket (timeout=0) is not supportedrzconnect: to)�
ValueErrorrrr~r[r`�create_connection)r&rerfrXs    r�_get_socketzSMTP._get_socket1sd����w��O�P�P��?�?�Q�����m�d�D�\�4�;N�;N�O��'�'��t��g�(,�(;�(;�=�	=rc��|r||_|sR|jd�|jd�k(r/|jd�}|dk\r|d|||dzd}}	t|�}|s|j}tjd|||�|j|||j�|_d|_|j�\}}|jdkDr|jdt!|��||fS#t$rtd��wxYw)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.

        �:rNruznonnumeric portzsmtplib.connect�connect:)r[�find�rfind�intr��OSError�default_portr{�auditr�rX�sockrv�getreplyrrr~�repr)r&rerfr[�ir'r(s       rr]zSMTP.connect;s����"0�D������3��4�:�:�c�?�:��
�
�3��A��A�v�!�"�1�X�t�A��E�F�|�d��5��t�9�D���$�$�D��	�	�#�T�4��6��$�$�T�4����>��	���	��m�m�o���s��?�?�Q�����j�$�s�)�4��c�{���"�5�!�"3�4�4�5�s�C.�.Dc��|jdkDr|jdt|��|jr_t	|t
�r|j
|j�}tjd||�	|jj|�ytd��#t$r|j�td��wxYw)zSend `s' to the server.rzsend:zsmtplib.send�Server not connectedzplease run connect() firstN)rrr~r�r��
isinstance�str�encoderZr{r��sendallr�r^r)r&�ss  r�sendz	SMTP.send\s����?�?�Q�����g�t�A�w�/��9�9��!�S�!��H�H�T�2�2�3���I�I�n�d�A�.�
E��	�	�!�!�!�$�
)�)E�F�F��	�
E��
�
��,�-C�D�D�
E�s�:B!�!%Cc���|dk(r|}n|�d|��}d|vsd|vr0|jdd�jdd�}td|����|j|�t���y)	zSend a command to the server.r7� �
�
z\nz\rz=command and arguments contain prohibited newline characters: N)�replacer�r�rI)r&�cmdr%r�s    r�putcmdzSMTP.putcmdosu���2�:��A��%�q����A��1�9���	��	�	�$��&�.�.�t�U�;�A��O�PQ�s�S��
�	
�	�	�Q�C��v�,�rc��g}|j� |jjd�|_		|jjtdz�}|s|j
�td��|jdkDr|jdt|��t|�tkDr|j
�tdd	��|j|d
djd��|dd}	t!|�}|dd
dk7rn��dj%|�}|jdkDr|jd|�d|���||fS#t
$r,}|j
�tdt|�z��d}~wwxYw#t"$rd
}Y��wxYw)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�rbruz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:i�zLine too long.�s 	
�����-�
zreply: retcode (z); Msg: )rvr��makefile�readline�_MAXLINEr�r^rr�rrr~r��lenr�appendr<r�r��join)r&�resp�line�er'�errcode�errmsgs       rr�z
SMTP.getreply|sz�����9�9���	�	�*�*�4�0�D�I��
7��y�y�)�)�(�Q�,�7��
��
�
��,�-M�N�N�����"��!�!�(�D��J�7��4�y�8�#��
�
��+�C�1A�B�B��K�K��Q�R����z�2�3����8�D�
��d�)��
�A�a�y�D� ��5�8���D�!���?�?�Q�������P�Q������9�
7��
�
��,�-O�/2�1�v�.6�7�7��
7��$�
����
�s)�"E�1E9�	E6�
'E1�1E6�9F�Fc�F�|j||�|j�S)z-Send a command, and return its response code.�r�r�)r&r�r%s   rrnz
SMTP.docmd�s�����C����}�}��rc�~�|jd|xs|j�|j�\}}||_||fS)zwSMTP 'helo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        �helo)r�r_r��	helo_resp)r&�namer'r(s    rr�z	SMTP.helo�s=��
	
���F�D�7�D�$7�$7�8��m�m�o���s�����c�{�rc���i|_|j|j|xs|j�|j	�\}}|dk(r)t|�dk(r|j
�td��||_|dk7r||fSd|_	t|jt�sJt|j���|jjd�jd�}|d=|D�]}tj!|�}|rB|jj#dd	�d
z|j%d�dz|jd<�]t'j d|�}|s�v|j)d�j+�}|j,|j/d�d
j1�}	|dk(r0|jj#|d	�d
z|	z|j|<��|	|j|<��||fS)zx SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        r�rr��Tzlatin-1r��authr7r�z((?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?�featureN)rYr��ehlo_msgr_r�r�r^r�	ehlo_resp�
does_esmtpr��bytesr��decode�split�
OLDSTYLE_AUTH�match�get�groupsrG�group�lower�string�endr<)
r&r�r'r(r��each�
auth_match�mr��paramss
          rrRz	SMTP.ehlo�s���
!������D�M�M�4�#>�4�+>�+>�?��m�m�o���s��2�:�#�c�(�a�-��J�J�L�(�)?�@�@�����3�;��#�;������$�.�.�%�0�F�$�t�~�~�2F�F�0��~�~�$�$�Y�/�5�5�d�;����G��	:�D�'�,�,�T�2�J��.2�.A�.A�.E�.E�f�b�.Q��/� *� 1� 1�!� 4�Q� 7�/8��#�#�F�+�����D�d�K�A���'�'�)�,�2�2�4�����!�%�%�	�"2�"3�4�:�:�<���f�$�37�3F�3F�3J�3J�7�TV�3W�!�4"�$*�4+�D�'�'��0�4:�D�'�'��0�5	:�6�c�{�rc�:�|j�|jvS)z7Does the server support a given SMTP service extension?)r�rY)r&�opts  r�has_extnz
SMTP.has_extn�s���y�y�{�d�1�1�1�1rc�L�|jd|�|j�dS)z;SMTP 'help' command.
        Returns help text from server.�helprur�r}s  rr�z	SMTP.help�s#��	
���F�D�!��}�}��q�!�!rc�2�d|_|jd�S)z&SMTP 'rset' command -- resets session.rT�rset)rZrnris rr�z	SMTP.rset�s�� '����z�z�&�!�!rc�D�	|j�y#t$rYywxYw)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�rris r�_rsetz
SMTP._rset�s"��	��I�I�K��%�	��	�s��	�c�$�|jd�S)z-SMTP 'noop' command -- doesn't do anything :>�noop)rnris rr�z	SMTP.noops���z�z�&�!�!rc��d}|rV|jrJtd�|D��r$|jd�rd|_nt	d��ddj|�z}|j
ddt|��|���|j�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.
        r7c3�BK�|]}|j�dk(���y�w)�smtputf8N)r�)�.0�xs  r�	<genexpr>zSMTP.mail.<locals>.<genexpr>s����:�Q�1�7�7�9�j�(�:�s�r�zutf-8z SMTPUTF8 not supported by serverr��mailzFROM:)	r��anyr�rZrr�r�rr�)r&r-�options�
optionlists    rr�z	SMTP.mails{���
��t����:�'�:�:��=�=��,�,3�D�)�/�:�<�<��s�x�x��0�0�J����F�9�V�+<�j�I�J��}�}��rc��d}|r |jrddj|�z}|jddt|��|���|j	�S)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r7r��rcptzTO:)r�r�r�rr�)r&�recipr�r�s    rr�z	SMTP.rcpt$sG���
��t����s�x�x��0�0�J����F��5�)9�:�F�G��}�}��rc���|jd�|j�\}}|jdkDr|jd||f�|dk7rt	||��t|t�rt|�jd�}t|�}|ddtk7r	|tz}|dztz}|j|�|j�\}}|jdkDr|jd||f�||fS)	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.
        rKrzdata:ibrT���N�.)r�r�rrr~r
r�r�rPr�rN�bCRLFr�)r&r(r'�repl�qs     rrKz	SMTP.data,s���	
���F���}�}����t��?�?�Q�����g��d�|�4��3�;���d�+�+��#�s�#���n�+�+�G�4���s�#�A����v�����I���D��5� �A��I�I�a�L��-�-�/�K�T�3�����"��!�!�'�D�#�;�7��#�;�rc�X�|jdt|��|j�S)z5SMTP 'verify' command -- checks for address validity.�vrfy�r�rCr��r&�addresss  r�verifyzSMTP.verifyI�!�����F�J�w�/�0��}�}��rc�X�|jdt|��|j�S)z.SMTP 'expn' command -- expands a mailing list.�expnr�r�s  rr�z	SMTP.expnPr�rc���|j�Y|j�Ld|j�dcxkrdks/n|j�\}}d|cxkrdksnt	||��yyyy)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�rRr�r)r&r'r�s   r�ehlo_or_helo_if_neededzSMTP.ehlo_or_helo_if_neededWsi���>�>�!�d�n�n�&<��4�9�9�;�q�>�0�S�0�#�y�y�{���t��t�*�s�*�'��d�3�3�+�1�'=�!rT��initial_response_okc�H�|j�}|r|�nd}|�?t|jd�d��}|jd|dz|z�\}}d|_n|jd|�\}}d|_|d	k(r�|xjdz
c_tj|�}t||�jd�d��}|j|�\}}|jtkDrtd
t||f�z��|d	k(r��|dvr||fSt||��)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.
        NrTr7)�eol�AUTHr�ruriNz4Server AUTH mechanism infinite loop. Last response: ���i�)�upper�
encode_base64r�rnr\�base64�decodebytes�
_MAXCHALLENGErr�r
)	r&�	mechanism�
authobjectr��initial_response�responser'r��	challenges	         rr�z	SMTP.authhs-��,�O�O�%�	�,?�J�L�T���'�$�%5�%<�%<�W�%E�2�N�H��:�:�f�i�#�o��.H�I�L�T�4�)*�D�&��:�:�f�i�8�L�T�4�)*�D�&��c�k��&�&�!�+�&��*�*�4�0�I�$��9�%�,�,�W�5�2�?�H��:�:�h�/�L�T�4��)�)�M�9�#�J��D�$�<�(�)����c�k��:���$�<��%�d�D�1�1rc��|�y|jdztj|jj	d�|d�j�zS)zh Authobject to use with CRAM-MD5 authentication. Requires self.user
        and self.password to be set.Nr�rT�md5)�user�hmac�HMAC�passwordr��	hexdigest�r&rs  r�
auth_cram_md5zSMTP.auth_cram_md5�sL������y�y�3������M�M� � ��)�9�e�"=�=F�Y�[�I�	Irc�:�d|j�d|j��S)ze Authobject to use with PLAIN authentication. Requires self.user and
        self.password to be set.�)rrrs  r�
auth_plainzSMTP.auth_plain�s��"�Y�Y��
�
�6�6rc�T�|�|jdkr|jS|jS)ze Authobject to use with LOGIN authentication. Requires self.user and
        self.password to be set.�)r\rrrs  r�
auth_loginzSMTP.auth_login�s+����� :� :�Q� >��9�9���=�=� rc���|j�|jd�std��|jdj	�}gd�}|D�cgc]}||vr|��
}}|std��||c|_|_|D]Q}d|j�jdd�z}		|j|t||	�|��\}
}|
d	vr|
|fcS�S
�cc}w#t$r}|}
Yd
}~�kd
}~wwxYw)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-MD5�PLAIN�LOGINz(No suitable authentication method found.�auth_�-�_r�r�N)
r�r�rrYr�rrrr�r�r��getattrr
)r&rrr��advertised_authlist�preferred_authsr��authlist�
authmethod�method_namer'r�r��last_exceptions              r�loginz
SMTP.login�s0��8	
�#�#�%��}�}�V�$�'�>�@�
@�#�1�1�&�9�?�?�A��9��&5�4�T��2�2��4��4��� J�K�K�
$(�� ��	�4�=�"�	#�J�!�J�$4�$4�$6�$>�$>�s�C�$H�H�K�	
#�#�y�y����k� :�(;� )� =���t�
�:�%� �$�<�'�&�	#����/4��&+�
#�!"���
#�s�
C�&(C�	C/�#C*�*C/)�contextc��|j�|jd�std��|jd�\}}|dk(rztstd��|�t
j�}|j|j|j��|_	d|_d|_d|_
i|_d|_||fSt!||��)	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 context parameter,
        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.�STARTTLSrUz&No SSL support included in this PythonN��server_hostnameF)r�r�rrn�	_have_ssl�RuntimeError�ssl�_create_stdlib_context�wrap_socketr�rWrvr�r�rYr�r)r&r&r��replys    rr(z
SMTP.starttls�s���"	
�#�#�%��}�}�Z�(�'�=�?�
?��
�
�:�.�
��u��3�;��"�#K�L�L����4�4�6���+�+�D�I�I�<@�J�J�,�H�D�I��D�I�
"�D�N�!�D�N�"$�D��#�D�O��e�}��(��e�4�4rc�z�|j�g}t|t�rt|�j	d�}|j
rF|j
d�r|jdt|�z�|D]}|j|��|j||�\}}	|dk7r3|dk(r|j�n|j�t||	|��i}
t|t�r|g}|D]H}|j||�\}}	|dk7r|dk7r||	f|
|<|dk(s�/|j�t|
��t|
�t|�k(r|j�t|
��|j|�\}}	|dk7r2|dk(r|j�n|j�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.

        rT�sizezsize=%dr�i��)r�r�r�rPr�r�r�r�r�r�r^r�rr�r	rKr
)r&�	from_addr�to_addrsr(�mail_options�rcpt_options�
esmtp_opts�optionr'r��senderrsr�s            r�sendmailz
SMTP.sendmails���@	
�#�#�%��
��c�3���C�.�'�'��0�C��?�?��}�}�V�$��!�!�)�c�#�h�"6�7�&�
*���!�!�&�)�
*��y�y��J�7���t��3�;��s�{��
�
���
�
��#�D�$�	�:�:����h��$� �z�H��	6�D��9�9�T�<�8�L�T�4����$�#�+�"&�������s�{��
�
��+�H�5�5�
	6��x�=�C��M�)��J�J�L�'��1�1��y�y��~���t��3�;��s�{��
�
���
�
����d�+�+��rc�0�|j�|jd�}|�d}nt|�dk(rd}ntd��|�=|dz|vr||dzn||dz}tj
j
|g�d	d}|�U||d
z||dz||dzfD�cgc]}|�|��}	}tj
j
|	�D�
cgc]}
|
d��	}}
tj|�}|d=|d
=d}	dj|g|��jd�tj�5}
|rEtjj!|
|j"j%d����}g|�d�d��}ntjj!|
�}|j'|d��|
j)�}ddd�|j+||||�Scc}wcc}
w#t$r!|jd�std��d}Y��wxYw#1swY�UxYw)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-DateNr7ruzResent-z0message has more than one 'Resent-' header block�Sender�Fromr�To�Bcc�Ccz
Resent-BccFrTr�z�One or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)�utf8)�policy�SMTPUTF8z
BODY=8BITMIMEr)�linesep)r��get_allr�r�r9r:�getaddresses�copyr�r��UnicodeEncodeErrorr�r�io�BytesIO�	generator�BytesGeneratorrD�clone�flatten�getvaluer<)r&r(r5r6r7r8�resent�
header_prefix�f�addr_fields�a�msg_copy�
international�bytesmsg�g�flatmsgs                r�send_messagezSMTP.send_message�s[��>	
�#�#�%����]�+���>��M�
��[�A�
�%�M��O�P�P��� -�x�7�C�?��]�X�5�6� #�M�F�$:� ;�
����0�0�)��=�a�@��C�I���'*�=�4�+?�'@�'*�=�5�+@�'A�'*�=�4�+?�'@�'B�-�� �m��-�K�-�',�k�k�&>�&>�{�&K�L���!��L�H�L��9�9�S�>���U�O��\�"��
�	!��G�G�Y�*��*�+�2�2�7�;��Z�Z�\�	*�X���O�O�2�2��S�Z�Z�%5�%5�4�%5�%@�3�B��K��K�z�K�?�K���O�O�2�2�8�<��
�I�I�h��I�/��'�'�)�G�	*��}�}�Y��'�<�)�+�	+��9-��M��"�	!��=�=��,�+�K�L�L�!�M�
	!��	*�	*�s+�G�G�7#G�.B
H�'H	�H	�Hc���	|j}d|_|r|j�|j}d|_|r|j�yy#|j}d|_|r|j�wwxYw)z(Close the connection to the SMTP server.N)rvr^r�)r&rvr�s   rr^z
SMTP.close�si��		��9�9�D��D�I���
�
���9�9�D��D�I���
�
�����9�9�D��D�I���
�
���s�%A�(A6c��|jd�}dx|_|_i|_d|_|j�|S)zTerminate the SMTP session.�quitNF)rnr�r�rYr�r^)r&�ress  rr_z	SMTP.quit�s;���j�j�� ��*.�.����� �������
�
���
r��	localhostrN)r7)rr")rr)NNrr)2rrrrrrr�rvr�r�r�r��	SMTP_PORTr�r`�_GLOBAL_DEFAULT_TIMEOUTr)rjrprsr~r�r]r�r�r�rnr�rRr�r�r�r�r�r�r�rKr�r�r�r�r�rrrr%r(r<r\r^r_rrrrr�s&���8�J��D��D��I��H��I��J��L��Q�t��7�7� $�.4�`��%�*�=��BG�& �/�b��1�f2�"�"�

�"��*��:�
�D��4�"BF�.2�`I�7�
!�<@�@�D#'�+�Z?A� �f�P:>�35�K+�Z�rrc�L��eZdZdZeZdejddd�d�Z�fd�Z	�xZ
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.  context also optional, can contain a
        SSLContext.

        N)rXr[r&c�r�|�tj�}||_tj	||||||�yr")r.r/r&rr))r&rerfr_rXr[r&s       rr)zSMTP_SSL.__init__�s7�����4�4�6��"�D�L��M�M�$��d�N�G�(�
*rc���|jdkDr|jd||f�t�|�
|||�}|jj||j��}|S)Nrr�r*)rrr~�superr�r&r0rW)r&rerfrX�
new_socket�	__class__s     �rr�zSMTP_SSL._get_sockets_�������"��!�!�*�t�T�l�;���,�T�4��A�J����1�1�*�BF�*�*�2�N�J��r)r7rN)rrrr�
SMTP_SSL_PORTr�r`rdr)r��
__classcell__�rks@rrfrf�s1���	�%��	*� &� >� >�$(�$�	*�	�	rrfi�c�R��eZdZdZdZdeddejf�fd�	Zd�fd�	Z	�xZ
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.�lhlor7Nc�.��t�|�|||||��y)zInitialize a new instance.)r_r[rXN)rir))r&rerfr_r[rXrks      �rr)z
LMTP.__init__ s#���	����t�N�(6��	�	Irc����|ddk7rt�|�|||��S|j�|jstd��	t	jtj
tj�|_|jtjur%|jj|j�d|_
|jj|�|j�\}}|jdkDr|jd|�||fS#t$rP|jdkDr|jd|�|jr|jj�d|_�wxYw)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.r�/)r[Nr�z
connect fail:r�)rir]rXr�r`�AF_UNIX�SOCK_STREAMr�rd�
settimeoutrvr�rrr~r^r�)r&rerfr[r'r(rks      �rr]zLMTP.connect&s$�����7�c�>��7�?�4��n�?�M�M��<�<�#�D�L�L��O�P�P�	��
�
�f�n�n�f�6H�6H�I�D�I��|�|�6�#A�#A�A��	�	�$�$�T�\�\�2��D�I��I�I���d�#��m�m�o���s��?�?�Q�����j�#�.��c�{����	�����"��!�!�/�4�8��y�y��	�	���!��D�I��
	�s�BD�AE+ra)rrrrr��	LMTP_PORTr`rdr)r]rmrns@rrprps1���4��H��Y�t� $�f�.L�.L�I��rrp�__main__c���tjj|dz�tjj�tjj�j
�S)Nz: )r{�stdout�write�flush�stdinr�r<)�prompts rrrEsD���
�
����$��'��
�
�����y�y�!�!�#�)�)�+�+rr?r@�,zEnter message, end with ^D:r7zMessage length is %drbru)Arr`rKrG�email.utilsr9�
email.message�email.generatorrrrIrxr{�email.base64mimerr�__all__rcrlrIr�r�r�compile�Ir�r�rrrrrr	r
rrr
rrCrrNrPr.r,�ImportErrorrrfr�rxrprr�fromaddrr��toaddrsrwr(r~r�r�r��serverrsr<r_rrr�<module>r�s)���R�	�	����
����
�9�-��

�	��
�
�������
���
�
�<����.�
�?�G�?��M���]�� �M� �(�-�(�
"�M�
"�2�)�2�1�,�1�-�)�-��3����5�/�8����I�i�i�V
��4��<�N�N�:��

�	�/�4�/�h�z��,�
�f�~�H��T�l� � ��%�G�	�
'�(�
�C��)�)�$�$�&�
&�$�
&��D�j���)�)�$�$�&�
&�$�
&�	�
 �3�s�8�
+�,�
�+�
�F�
���!��
�O�O�H�g�s�+�
�K�K�M�#��Y���I��s� G�G#�"G#

Zerion Mini Shell 1.0