AlkantarClanX12

Your IP : 3.145.33.230


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/smtplib.cpython-34.pyc

�
e f;��@sNdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZ
ddlmZddddd	d
ddd
dddgZdZdZdZdZdZejdej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGdd
�d
e�ZGdd�de�Z Gdd�de�Z!Gdd
�d
e�Z"d d�Z#d!d"�Z$d#d�Z%d$d%�Z&d&d'�Z'yddl(Z(Wne)k
rd(Z*YnXd)Z*Gd*d�d�Z+e*raGd+d,�d,e+�Z,ej-d,�nd-Z.Gd.d/�d/e+�Z/e0d0krJddlZd1d2�Z1e1d3�Z2e1d4�j3d5�Z4e5d6�d7Z6x(ej7j8�Z9e9r�Pne6e9Z6q�We5d8e:e6��e+d9�Z;e;j<d:�e;j=e2e4e6�e;j>�ndS);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)�stderr�
SMTPException�SMTPServerDisconnected�SMTPResponseException�SMTPSenderRefused�SMTPRecipientsRefused�
SMTPDataError�SMTPConnectError�
SMTPHeloError�SMTPAuthenticationError�	quoteaddr�	quotedata�SMTP�i�z
s
i z	auth=(.*)c@seZdZdZdS)rz4Base class for all exceptions raised by this module.N)�__name__�
__module__�__qualname__�__doc__�rr�,/opt/alt/python34/lib64/python3.4/smtplib.pyrFsc@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.
    N)rrrrrrrrrIsc@s"eZdZdZdd�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__Zs		zSMTPResponseException.__init__N)rrrrrrrrrrQsc@s"eZdZdZdd�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.
    cCs1||_||_||_|||f|_dS)N)rr�senderr)rrrrrrrrfs			zSMTPSenderRefused.__init__N)rrrrrrrrrr_sc@s"eZdZdZdd�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|_dS)N)�
recipientsr)rrrrrrts	zSMTPRecipientsRefused.__init__N)rrrrrrrrrrlsc@seZdZdZdS)r	z'The SMTP server didn't accept the data.N)rrrrrrrrr	ysc@seZdZdZdS)r
z&Error during connection establishment.N)rrrrrrrrr
|sc@seZdZdZdS)rz"The server refused our HELO reply.N)rrrrrrrrrsc@seZdZdZdS)rzvAuthentication error.

    Most probably the server didn't accept the username/password
    combination provided.
    N)rrrrrrrrr�scCsStjj|�\}}||fdkrK|j�jd�rC|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.
    ��<z<%s>)r r )�email�utils�	parseaddr�strip�
startswith)�
addrstring�displayname�addrrrrr
�scCs2tjj|�\}}||fdkr.|S|S)Nr )r r )r"r#r$)r'r(r)rrr�
_addr_only�sr*cCs"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..z(?:\r\n|\n|\r(?!\n)))�re�sub�CRLF)�datarrrr�scCstjdd|�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�sr0FTc@s�eZdZdZdZdZdZdZdZdZ	e
Zdddej
ddd�Zdd	�Zd
d�Zdd
�Zdd�Zddddd�Zdd�Zddd�Zdd�Zddd�Zddd�Zddd�Zdd �Zdd!d"�Zd#d$�Zd%d&�Zd'd(�Zgd)d*�Zgd+d,�Z d-d.�Z!d/d0�Z"e"Z#d1d2�Z$d3d4�Z%d5d6�Z&dddd7d8�Z'ggd9d:�Z(ddgid;d<�Z)d=d>�Z*d?d@�Z+dS)Ara�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|_||_|rc|j||�\}}|dkrct||��qcn|dk	r{||_nhtj�}d|kr�||_nDd}	ytj	tj
��}	Wntjk
r�YnXd|	|_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.

        ��N�.z	127.0.0.1z[%s])�_host�timeout�esmtp_features�source_address�connectr
�local_hostname�socketZgetfqdnZ
gethostbynameZgethostnameZgaierror)
r�host�portr9r5r7rrZfqdnr)rrrr�s&				z
SMTP.__init__cCs|S)Nr)rrrr�	__enter__szSMTP.__enter__cGsbzPy7|jd�\}}|dkr9t||��nWntk
rNYnXWd|j�XdS)NZQUIT��)�docmdrr�close)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)rrCrrr�set_debuglevelszSMTP.set_debuglevelcCsM|jdkr1td||f|jdt�ntj||f||j�S)Nrzconnect: to�file)rC�printr7rr:�create_connection)rr;r<r5rrr�_get_sockets

zSMTP._get_socket�	localhostc
CsP|r||_n|r�|jd�|jd�kr�|jd�}|dkr�|d|�||dd�}}yt|�}Wq�tk
r�td��Yq�Xq�n|s�|j}n|jdkr�td||fdt	�n|j
|||j�|_d|_
|j�\}}|jdkrFtd|dt	�n||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.

        �:rN�znonnumeric portzconnect:rE)r7�find�rfind�int�
ValueError�OSError�default_portrCrFrrHr5�sockrE�getreply)rr;r<r7�irrrrrr8&s(%%
	zSMTP.connectcCs�|jdkr+tdt|�dt�nt|d�r�|jr�t|t�rd|jd�}ny|jj	|�Wq�t
k
r�|j�td��Yq�Xntd��dS)	zSend `s' to the server.rzsend:rErR�asciizServer not connectedzplease run connect() firstN)
rCrF�reprr�hasattrrR�
isinstance�str�encodeZsendallrPr@r)r�srrr�sendHs

z	SMTP.sendcCsC|dkrd|tf}nd||tf}|j|�dS)zSend a command to the server.r z%s%sz%s %s%sN)r-r\)r�cmdrrYrrr�putcmdWszSMTP.putcmdcCs�g}|jdkr-|jjd�|_nxTy|jjtd�}WnEtk
r�}z%|j�tdt|���WYdd}~XnX|s�|j�td��n|j	dkr�t
dt|�dt�nt
|�tkr
|j�td	d
��n|j|dd�jd��|dd
�}yt|�}Wntk
red}PYnX|d
d�dkr0Pq0q0Wdj|�}|j	dkr�t
d||fdt�n||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�rbrKz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:rEi�zLine too long.�s 	
��-s
zreply: retcode (%s); Msg: %s���)rErR�makefile�readline�_MAXLINErPr@rrYrCrFrVr�lenr�appendr%rNrO�join)r�resp�line�erZerrcode�errmsgrrrrS_s@

#

 

z
SMTP.getreplycCs|j||�|j�S)z-Send a command, and return its response code.)r^rS)rr]rrrrr?�sz
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)r^r9rS�	helo_resp)r�namerrrrrrn�s	z	SMTP.heloc
Cs�i|_|j|j|p!|j�|j�\}}|d
krnt|�dkrn|j�td��n||_|dkr�||fSd|_	t
|jt�s�tt
|j���|jjd�jd�}|d=x�|D]�}tj|�}|r8|jjdd�d	|jd�d|jd<q�ntjd
|�}|r�|jd�j�}|j|jd�d�j�}	|dkr�|jj|d�d	|	|j|<q�|	|j|<q�q�W||fS)zx SMTP 'ehlo' command.
        Hostname to send for this command defaults to the FQDN of the local
        host.
        rKrzServer not connected�zlatin-1�
�authr � z((?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*) ?�featureNrc)r6r^�ehlo_msgr9rSrgr@r�	ehlo_resp�
does_esmtprX�bytes�AssertionErrorrV�decode�split�
OLDSTYLE_AUTH�match�get�groupsr+�group�lower�string�endr%)
rrprrrj�eachZ
auth_match�mruZparamsrrrr1�s4	
	
	'
1"'z	SMTP.ehlocCs|j�|jkS)z7Does the server support a given SMTP service extension?)r�r6)rZoptrrr�has_extn�sz
SMTP.has_extncCs|jd|�|j�dS)z;SMTP 'help' command.
        Returns help text from server.�helprK)r^rS)rrrrrr��sz	SMTP.helpcCs
|jd�S)z&SMTP 'rset' command -- resets session.�rset)r?)rrrrr��sz	SMTP.rsetcCs'y|j�Wntk
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)r�r)rrrr�_rset�s
z
SMTP._rsetcCs
|jd�S)z-SMTP 'noop' command -- doesn't do anything :>�noop)r?)rrrrr��sz	SMTP.noopcCsUd}|r+|jr+ddj|�}n|jddt|�|f�|j�S)z0SMTP 'mail' command -- begins mail xfer session.r rt�mailz	FROM:%s%s)rxrir^r
rS)rr�options�
optionlistrrrr��s
 z	SMTP.mailcCsUd}|r+|jr+ddj|�}n|jddt|�|f�|j�S)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r rt�rcptzTO:%s%s)rxrir^r
rS)rZrecipr�r�rrrr��s
 z	SMTP.rcptcCs$|jd�|j�\}}|jdkrJtd||fdt�n|dkrht||��n�t|t�r�t|�j	d�}nt
|�}|d
d�tkr�|t}n|d	t}|j|�|j�\}}|jdkrtd||fdt�n||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.
        r.rzdata:rEibrU�N�.���)
r^rSrCrFrr	rXrYr0rZr/�bCRLFr\)rrr�repl�qrrrr.s"



z	SMTP.datacCs |jdt|��|j�S)z5SMTP 'verify' command -- checks for address validity.�vrfy)r^r*rS)r�addressrrr�verifyszSMTP.verifycCs |jdt|��|j�S)z.SMTP 'expn' command -- expands a mailing list.�expn)r^r*rS)rr�rrrr�&sz	SMTP.expncCs�|jdkr�|jdkr�d|j�dko?dkns�|j�\}}d|komdkns�t||��q�q�ndS)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+)rorwr1rnr)rrrjrrr�ehlo_or_helo_if_needed-s
&zSMTP.ehlo_or_helo_if_neededc
	s�dd�}dd�}d}d}d}|j�|jd�sRtd	��n|jdj��|||g}�fd
d�|D�}	|	s�td��nx2|	D]*}
|
|kr|jd
|�\}}|dkr�|j||||��\}}q�n�|
|kr>|jd
|d|||��\}}n|
|kr�|jd
d|t|jd�dd�f�\}}|dkr�|jt|jd�dd��\}}q�n|dkr�||fSq�Wt||��dS)aALog in on an SMTP server that requires authentication.

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

        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.
         SMTPException            No suitable authentication method was
                                  found.
        cSsTtj|�}|dtj|jd�|d�j�}t|jd�dd�S)NrtrUZmd5�eolr )�base64Zdecodebytes�hmacZHMACrZZ	hexdigest�
encode_base64)Z	challenge�user�passwordZresponserrr�encode_cram_md5Tsz#SMTP.login.<locals>.encode_cram_md5cSs)d||f}t|jd�dd�S)NZ%s%srUr�r )r�rZ)r�r�r[rrr�encode_plainZsz SMTP.login.<locals>.encode_plainZPLAINzCRAM-MD5ZLOGINrsz,SMTP AUTH extension not supported by server.cs"g|]}|�kr|�qSrr)�.0rs)�advertised_authlistrr�
<listcomp>qs	zSMTP.login.<locals>.<listcomp>z(No suitable authentication method found.ZAUTHiNrtz%s %srUr�r ���N)r�r�)	r�r�rr6r|r?r�rZr)
rr�r�r�r�Z
AUTH_PLAINZ
AUTH_CRAM_MD5Z
AUTH_LOGINZpreferred_authsZauthlistZ
authmethodrrjr)r�r�login>s:

'	#	.0z
SMTP.logincCs:|j�|jd�s(td��n|jd�\}}|dkr!ts^td��n|dk	r�|dk	r�td��n|dk	r�|dk	r�td��n|dkr�tjd	|d
|�}n|j	|j
d|j�|_
d|_d|_
d|_i|_d|_nt||��||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.ZSTARTTLSr2z&No SSL support included in this PythonNz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusive�certfile�keyfile�server_hostnamer)r�r�rr?�	_have_ssl�RuntimeErrorrO�ssl�_create_stdlib_context�wrap_socketrRr4rErorwr6rxr)rr�r��contextrjZreplyrrrr��s.
				z
SMTP.starttlscCs|j�g}t|t�r7t|�jd�}n|jr�|jd�ri|jdt|��nx|D]}|j|�qpWn|j	||�\}}	|dkr�|dkr�|j
�n
|j�t||	|��ni}
t|t�r|g}nxv|D]n}|j
||�\}}	|dkrW|dkrW||	f|
|<n|dkr|j
�t|
��qqWt|
�t|�kr�|j�t|
��n|j|�\}}	|dkr|dkr�|j
�n
|j�t||	��n|
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).

        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.

        rU�sizezsize=%drqi��)r�rXrYr0rZrxr�rhrgr�r@r�rr�rr.r	)r�	from_addr�to_addrsr�mail_options�rcpt_optionsZ
esmtp_optsZoptionrrjZsenderrsr�rrr�sendmail�sF=
	







z
SMTP.sendmailc
Csd|jd�}|dkr$d}n't|�dkr?d}ntd��|dkr�|d|kru||dn||d}n|dkr�d	d
�||d||d||d
fD�}dd
�tjj|�D�}ntj|�}	|	d=|	d=tj��8}
tj	j
|
�}|j|	dd�|
j�}WdQX|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.

        zResent-DateNr rKzResent-z0message has more than one 'Resent-' header blockZSender�FromcSs"g|]}|dk	r|�qS)Nr)r��frrrr�Ns	z%SMTP.send_message.<locals>.<listcomp>�ToZBccZCccSsg|]}|d�qS)rKr)r��arrrr�Qs	z
Resent-Bcc�linesepz
)Zget_allrgrOr"r#Zgetaddresses�copy�io�BytesIOZ	generatorZBytesGeneratorZflatten�getvaluer�)
rrr�r�r�r�ZresentZ
header_prefixZaddr_fieldsZmsg_copyZbytesmsg�gZflatmsgrrr�send_message(s.		"zSMTP.send_messagecCsVz)|j}d|_|r(|j�nWd|j}d|_|rQ|j�nXdS)z(Close the connection to the SMTP server.N)rEr@rR)rrErRrrrr@]s				z
SMTP.closecCs?|jd�}d|_|_i|_d|_|j�|S)zTerminate the SMTP session.�quitNF)r?rwror6rxr@)r�resrrrr�js		
z	SMTP.quit),rrrrrCrErorvrwrx�	SMTP_PORTrQr:�_GLOBAL_DEFAULT_TIMEOUTrr=rBrDrHr8r\r^rSr?rnr1r�r�r�r�r�r�r�r.r�r�r�r�r�r�r�r�r@r�rrrrr�sT	+
		"2
3P3f4
c
@sOeZdZdZeZdddddejdddd�Zdd�Z	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��n|dk	rN|dk	rNtd��n||_||_|dkr�tjd|d|�}n||_tj||||||�dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiver�r�)rOr�r�r�r�r�rr)	rr;r<r9r�r�r5r7r�rrrr�s			zSMTP_SSL.__init__cCsh|jdkr+td||fdt�ntj||f||j�}|jj|d|j�}|S)Nrzconnect:rEr�)	rCrFrr:rGr7r�r�r4)rr;r<r5Z
new_socketrrrrH�szSMTP_SSL._get_socket)
rrrr�
SMTP_SSL_PORTrQr:r�rrHrrrrr�vs	r�i�c@sIeZdZdZdZdedddd�Zdddd	d
�ZdS)�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 NcCs#tj|||d|d|�dS)zInitialize a new instance.r9r7N)rr)rr;r<r9r7rrrr�sz
LMTP.__init__rIrc
Cs|ddkr)tj|||d|�Sy8tjtjtj�|_d|_|jj|�Wn\tk
r�|jdkr�t	d|dt
�n|jr�|jj�nd|_�YnX|j�\}}|jdkr�t	d|dt
�n||fS)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.r�/r7Nz
connect fail:rEzconnect:)
rr8r:ZAF_UNIXZSOCK_STREAMrRrErPrCrFrr@rS)rr;r<r7rrrrrr8�s"	
		zLMTP.connect)rrrrrv�	LMTP_PORTrr8rrrrr��s
	r��__main__cCs4tjj|d�tjj�tjj�j�S)Nz: )�sys�stdout�write�flush�stdinrer%)�promptrrrr��s
r�r�r��,zEnter message, end with ^D:r zMessage length is %drIrK)?rr:r�r+Zemail.utilsr"Z
email.messageZemail.generatorr�r�r�Zemail.base64mimerr�r�r�__all__r�r�r-r�rf�compile�Ir}rPrrrrrr	r
rrr
r*rr/r0r��ImportErrorr�rr�rhr�r�rr�Zfromaddrr|ZtoaddrsrFrr�rerkrgZserverrDr�r�rrrr�<module>!s�			


	
���,/