HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.5/__pycache__/smtplib.cpython-35.pyc


FaI@sWdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZdddddd	d
ddd
ddgZdZdZdZdZdZejdejZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd	d	eZ Gdd
d
eZ!GdddeZ"Gd ddeZ#d!d
Z$d"d#Z%d$dZ&d%d&Z'd'd(Z(yddl)Z)Wne*k
r9d)Z+YnXd*Z+Gd+ddZ,e+r|Gd,d-d-e,Z-ej.d-d.Z/Gd/d0d0e,Z0e1d1krSd2d3Z2e2d4Z3e2d5j4d6Z5e6d7d8Z7x%ej8j9Z:e:rPe7e:Z7qWe6d9e;e7e,d:Z<e<j=d;e<j>e3e5e7e<j?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
SMTPExceptionSMTPServerDisconnectedSMTPResponseExceptionSMTPSenderRefusedSMTPRecipientsRefused
SMTPDataErrorSMTPConnectError
SMTPHeloErrorSMTPAuthenticationError	quoteaddr	quotedataSMTPiz
s
i z	auth=(.*)c@seZdZdZdS)rz4Base class for all exceptions raised by this module.N)__name__
__module____qualname____doc__rr/usr/lib/python3.5/smtplib.pyrGsc@seZdZdZdS)SMTPNotSupportedErrorzThe 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.
    N)rrrrrrrrrJsrc@seZdZdZdS)rzNot 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.
    N)rrrrrrrrrQsc@s"eZdZdZddZdS)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_errorargs)selfcodemsgrrr__init__bs		zSMTPResponseException.__init__N)rrrrrrrrrrYsc@s"eZdZdZddZdS)rzSender address refused.

    In addition to the attributes set by on all SMTPResponseException
    exceptions, this sets `sender' to the string that the SMTP refused.
    cCs1||_||_||_|||f|_dS)N)rrsenderr)rrrrrrrrns			zSMTPSenderRefused.__init__N)rrrrrrrrrrgsc@s"eZdZdZddZdS)rzAll 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|_dS)N)
recipientsr)rrrrrr|s	zSMTPRecipientsRefused.__init__N)rrrrrrrrrrtsc@seZdZdZdS)rz'The SMTP server didn't accept the data.N)rrrrrrrrrsc@seZdZdZdS)r	z&Error during connection establishment.N)rrrrrrrrr	sc@seZdZdZdS)r
z"The server refused our HELO reply.N)rrrrrrrrr
sc@seZdZdZdS)rzvAuthentication error.

    Most probably the server didn't accept the username/password
    combination provided.
    N)rrrrrrrrrscCsStjj|\}}||fdkrK|jjdrC|Sd|Sd|S)zQuote a subset of the email addresses defined by RFC 821.

    Should be able to handle anything email.utils.parseaddr can handle.
    <z<%s>)r r )emailutils	parseaddrstrip
startswith)
addrstringdisplaynameaddrrrrrscCs2tjj|\}}||fdkr.|S|S)Nr )r r )r"r#r$)r'r(r)rrr
_addr_onlysr*cCs"tjddtjdt|S)zQuote data for email.

    Double leading '.', and change Unix newline '\n', or Mac '\r' into
    Internet CRLF end-of-line.
    z(?m)^\.z..z(?:\r\n|\n|\r(?!\n)))resubCRLF)datarrrr
scCstjdd|S)Ns(?m)^\.s..)r+r,)Zbindatarrr_quote_periodssr/cCstjdt|S)Nz(?:\r\n|\n|\r(?!\n)))r+r,r-)r.rrr	_fix_eolssr0FTc@s>eZdZdZdZdZdZdZdZdZ	e
Zdddej
dddZdd	Zd
dZdd
ZddZddZdddddZddZdddZddZdddZdddZddd Zd!d"Zdd#d$Zd%d&Zd'd(Zd)d*Zgd+d,Z gd-d.Z!d/d0Z"d1d2Z#e#Z$d3d4Z%d5d6Z&d7d8d9d:Z'dd;d<Z(dd=d>Z)dd?d@Z*d7d8dAdBZ+ddddCdDZ,ggdEdFZ-ddgidGdHZ.dIdJZ/dKdLZ0dS)MraThis 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.
        rNehlor c
Cs||_||_i|_d|_||_|rf|j||\}}|dkrft|||dk	r~||_nhtj	}d|kr||_nDd}	ytj
tj}	Wntjk
rYnXd|	|_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.

        asciiN.z	127.0.0.1z[%s])
_hosttimeoutesmtp_featurescommand_encodingsource_addressconnectr	local_hostnamesocketZgetfqdnZ
gethostbynameZgethostnameZgaierror)
rhostportr;r6r9rrZfqdnr)rrrrs(					z
SMTP.__init__cCs|S)Nr)rrrr	__enter__szSMTP.__enter__cGs_zMy4|jd\}}|dkr6t||Wntk
rKYnXWd|jXdS)NZQUIT)docmdrrclose)rrrmessagerrr__exit__s
	z
SMTP.__exit__cCs
||_dS)zSet 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)rrErrrset_debuglevelszSMTP.set_debuglevelcGsN|jdkr7ttjjj|dtjnt|dtjdS)Nfile)rEprintdatetimeZnowZtimesysstderr)rrrrr_print_debug&s(zSMTP._print_debugcCsG|jdkr+|jd||f|jtj||f||jS)Nrzconnect: to)rErMr9r<create_connection)rr=r>r6rrr_get_socket,szSMTP._get_socket	localhostcCs>|r||_|r|jd|jdkr|jd}|dkr|d|||dd}}yt|}Wntk
rtdYnX|s|j}|jdkr|jd||f|j	|||j
|_d|_|j
\}}|jdkr4|jdt|||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.

        :rNrGznonnumeric portzconnect:)r9findrfindint
ValueErrorOSErrordefault_portrErMrOr6sockrHgetreplyrepr)rr=r>r9irrrrrr:4s(	%%
		zSMTP.connectcCs|jdkr%|jdt|t|dr|jrt|tr^|j|j}y|jj	|Wqt
k
r|jtdYqXntddS)zSend `s' to the server.rzsend:rXzServer not connectedzplease run connect() firstN)
rErMrZhasattrrX
isinstancestrencoder8ZsendallrVrBr)rsrrrsendVs

z	SMTP.sendcCsC|dkrd|tf}nd||tf}|j|dS)zSend a command to the server.r z%s%sz%s %s%sN)r-ra)rcmdrr^rrrputcmdhszSMTP.putcmdcCsg}|jdkr*|jjd|_xEy|jjtd}WnEtk
r}z%|jtdt|WYdd}~XnX|s|jtd|j	dkr|j
dt|t|tkr|jt
dd	|j|d
djd|dd}yt|}Wntk
rVd}PYnX|dd
d
kr-Pq-Wdj|}|j	dkr|j
d||f||fS)aGet 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.
        NrbrGz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:izLine too long.s 	
-s
zreply: retcode (%s); Msg: %a)rHrXZmakefilereadline_MAXLINErVrBrr^rErMrZlenrappendr%rTrUjoin)rresplineerZerrcodeerrmsgrrrrYps>

#

 
z
SMTP.getreplycCs|j|||jS)z-Send a command, and return its response code.)rcrY)rrbrrrrrAsz
SMTP.docmdcCs>|jd|p|j|j\}}||_||fS)zwSMTP 'helo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        helo)rcr;rY	helo_resp)rnamerrrrrrrs	z	SMTP.heloc
Csi|_|j|j|p!|j|j\}}|d
krkt|dkrk|jtd||_|dkr||fSd|_	t
|jtstt
|j|jjdjd}|d=x|D]}tj|}|r2|jjddd	|jdd|jd<qtjd
|}|r|jdj}|j|jddj}	|dkr|jj|dd	|	|j|<q|	|j|<qW||fS)zx SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        rGrzServer not connectedzlatin-1
authr  z((?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?featureNrh)r7rcehlo_msgr;rYrkrBr	ehlo_resp
does_esmtpr]bytesAssertionErrorrZdecodesplit
OLDSTYLE_AUTHmatchgetgroupsr+grouplowerstringendr%)
rrtrrrneachZ
auth_matchmryZparamsrrrr1s4	
	
	'
1"'z	SMTP.ehlocCs|j|jkS)z7Does the server support a given SMTP service extension?)rr7)rZoptrrrhas_extnsz
SMTP.has_extncCs|jd||jdS)z;SMTP 'help' command.
        Returns help text from server.helprG)rcrY)rrrrrrsz	SMTP.helpcCsd|_|jdS)z&SMTP 'rset' command -- resets session.r2rset)r8rA)rrrrrs	z	SMTP.rsetcCs'y|jWntk
r"YnXdS)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)rr)rrrr_rsets
z
SMTP._rsetcCs
|jdS)z-SMTP 'noop' command -- doesn't do anything :>noop)rA)rrrrrsz	SMTP.noopcCsd}|rh|jrhtdd|DrU|jdrId|_ntdddj|}|jdd	t||f|jS)
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!|]}|jdkVqdS)smtputf8N)r).0xrrr	<genexpr>szSMTP.mail.<locals>.<genexpr>rzutf-8z SMTPUTF8 not supported by serverrxmailz	FROM:%s%s)	r|anyrr8rrmrcrrY)rroptions
optionlistrrrrs		 z	SMTP.mailcCsRd}|r(|jr(ddj|}|jddt||f|jS)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r rxrcptzTO:%s%s)r|rmrcrrY)rZreciprrrrrrs
 z	SMTP.rcptcCs|jd|j\}}|jdkrD|jd||f|dkrbt||nt|trt|jd}t	|}|d	dt
kr|t
}|dt
}|j||j\}}|jdkr|jd||f||fSdS)
aSMTP '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.
        r.rzdata:ibr2N.)rcrYrErMrr]r^r0r_r/bCRLFra)rrrreplqrrrr. s"



z	SMTP.datacCs |jdt||jS)z5SMTP 'verify' command -- checks for address validity.vrfy)rcr*rY)raddressrrrverify=szSMTP.verifycCs |jdt||jS)z.SMTP 'expn' command -- expands a mailing list.expn)rcr*rY)rrrrrrDsz	SMTP.expncCs|jdkr|jdkrd|jdko?dkns|j\}}d|komdknst||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.
        Nri+)rsr{r1rrr
)rrrnrrrehlo_or_helo_if_neededKs
&zSMTP.ehlo_or_helo_if_neededinitial_response_okTc	Cs|j}|r|nd}|dk	rkt|jddd}|jd|d|\}}n|jd|\}}|dkrtj|}t||jddd}|j|\}}|d
kr||fSt||dS)aAuthentication 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
        bytes data 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.
        Nr2Zeolr ZAUTHrxiN)rr)upper
encode_base64r_rAbase64Zdecodebytesr)	rZ	mechanismZ
authobjectrZinitial_responseZresponserrn	challengerrrrw\s#
z	SMTP.authcCs@|dkrdS|jdtj|jjd|djS)zh Authobject to use with CRAM-MD5 authentication. Requires self.user
        and self.password to be set.Nrxr2Zmd5)userhmacZHMACpasswordr_Z	hexdigest)rrrrr
auth_cram_md5s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)rr)rrrrr
auth_plainszSMTP.auth_plaincCs|dkr|jS|jSdS)ze Authobject to use with LOGIN authentication. Requires self.user and
        self.password to be set.N)rr)rrrrr
auth_loginszSMTP.auth_logincs+|j|jds%td|jdjdddg}fdd|D}|srtd|||_|_x|D]}d	|jj	d
d}yA|j
|t||d|\}}	|dkr||	fSWqtk
r}
z|
}WYdd}
~
XqXqW|dS)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.
        rwz,SMTP AUTH extension not supported by server.zCRAM-MD5ZPLAINZLOGINcs"g|]}|kr|qSrr)rrw)advertised_authlistrr
<listcomp>s	zSMTP.login.<locals>.<listcomp>z(No suitable authentication method found.Zauth_-_rrN)rr)
rrrr7rrrrrreplacerwgetattrr)rrrrZpreferred_authsZauthlistZ
authmethodZmethod_namerrnrpZlast_exceptionr)rrlogins*
	
z
SMTP.logincCs+|j|jds%td|jd\}}|dkrtsXtd|dk	r||dk	r|td|dk	r|dk	rtd|dkrtjd	|d
|}|j	|j
d|j|_
d|_d|_
d|_i|_d|_nt||||fS)
aPuts 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.ZSTARTTLSr3z&No SSL support included in this PythonNz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusivecertfilekeyfileserver_hostnamer)rrrrA	_have_sslRuntimeErrorrUssl_create_stdlib_contextwrap_socketrXr5rHrsr{r7r|r)rrrcontextrnZreplyrrrrs0
						z
SMTP.starttlscCs|jg}t|tr4t|jd}|jr|jdrc|jdt|x|D]}|j|qjW|j	||\}}	|dkr|dkr|j
n
|jt||	|i}
t|tr|g}xp|D]h}|j
||\}}	|dkrE|dkrE||	f|
|<|dkr|j
t|
qWt|
t|kr|jt|
|j|\}}	|dkr|dkr|j
n
|jt||	|
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.

        r2sizezsize=%drui)rr]r^r0r_r|rrlrkrrBrrrrr.r)r	from_addrto_addrsrmail_optionsrcpt_optionsZ
esmtp_optsZoptionrrnZsenderrsrrrrsendmailsF@
	


	




z
SMTP.sendmailcCs|j|jd}|dkr.d}n't|dkrId}ntd|dkr|d|kr||dn||d}|dkrd	d
||d||d||d
fD}dd
tjj|D}tj|}	|	d=|	d=d}
y#dj|f|j	dWn3t
k
rg|jds]tdd}
YnXt
jx}|
rtjj|d|jjdd}|ddg7}ntjj|}|j|	dd|j}
WdQRX|j|||
||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 rGzResent-z0message has more than one 'Resent-' header blockZSenderFromcSs"g|]}|dk	r|qS)Nr)rfrrrrs	z%SMTP.send_message.<locals>.<listcomp>ToZBccZCccSsg|]}|dqS)rGr)rarrrrs	z
Resent-BccFr2rzOne or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityTpolicyutf8ZSMTPUTF8z
BODY=8BITMIMElinesepz
)rZget_allrkrUr"r#Zgetaddressescopyrmr_UnicodeEncodeErrorrrioBytesIO	generatorZBytesGeneratorrZcloneZflattengetvaluer)rrrrrrZresentZ
header_prefixZaddr_fieldsZmsg_copyZ
internationalZbytesmsggZflatmsgrrrsend_messagewsH
		#
		zSMTP.send_messagecCsPz&|j}d|_|r%|jWd|j}d|_|rK|jXdS)z(Close the connection to the SMTP server.N)rHrBrX)rrHrXrrrrBs				z
SMTP.closecCs?|jd}d|_|_i|_d|_|j|S)zTerminate the SMTP session.quitNF)rAr{rsr7r|rB)rZresrrrrs		
z	SMTP.quit)1rrrrrErHrsrzr{r|	SMTP_PORTrWr<_GLOBAL_DEFAULT_TIMEOUTrr?rDrFrMrOr:rarcrYrArrr1rrrrrrrr.rrrrrwrrrrrrrrBrrrrrrs^	,
	"1
3'	B4gK
c
@sOeZdZdZeZdddddejddddZddZ	dS)	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|dk	r$|dk	r$td|dk	rH|dk	rHtd||_||_|dkr~tjd|d|}||_tj||||||dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverr)rUrrrrrrr)	rr=r>r;rrr6r9rrrrrs				zSMTP_SSL.__init__cCsb|jdkr%|jd||ftj||f||j}|jj|d|j}|S)Nrzconnect:r)rErMr<rNr9rrr5)rr=r>r6Z
new_socketrrrrOszSMTP_SSL._get_socket)
rrrr
SMTP_SSL_PORTrWr<rrrOrrrrrs	ric@sIeZdZdZdZdeddddZdddd	d
ZdS)LMTPaLMTP - 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 NcCs#tj|||d|d|dS)zInitialize a new instance.r;r9N)rr)rr=r>r;r9rrrrsz
LMTP.__init__rPrcCs|ddkr)tj|||d|Sy8tjtjtj|_d|_|jj|WnStk
r|jdkr|j	d||jr|jj
d|_YnX|j\}}|jdkr|j	d|||fS)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.r/r9Nz
connect fail:zconnect:)rr:r<ZAF_UNIXZSOCK_STREAMrXrHrVrErMrBrY)rr=r>r9rrrrrr:%s"	
	
	zLMTP.connect)rrrrrz	LMTP_PORTrr:rrrrrs
	r__main__cCs4tjj|dtjjtjjjS)Nz: )rKstdoutwriteflushstdinrir%)promptrrrr?s
rrr,zEnter message, end with ^D:r zMessage length is %drPrG)@rr<rr+Zemail.utilsr"Z
email.messageZemail.generatorrrrrJrKZemail.base64mimerr__all__rrr-rrjcompileIrrVrrrrrrrr	r
rrr*r
r/r0rImportErrorrrrrlrrrrZfromaddrrZtoaddrsrIrrrirorkZserverrFrrrrrr<module>!s			


	
 ,
/