B °-_°¬ã @sndZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZdddddd d d d d ddg ZdZdZdZdZdZe dej¡ZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZ Gdd „d eƒZ!Gdd „d eƒZ"Gd d „d eƒZ#d!d „Z$d"d#„Z%d$d„Z&d%d&„Z'd'd(„Z(y ddl)Z)Wne*k r”d)Z+YnXd*Z+Gd+d„dƒZ,e+rÈGd,d-„d-e,ƒZ-e .d-¡d.Z/Gd/d0„d0e,ƒZ0e1d1krjd2d3„Z2e2d4ƒZ3e2d5ƒ 4d6¡Z5e6d7ƒd8Z7x e j8 9¡Z:e:s$Pe7e:Z7qWe6d9e;e7ƒƒe,d:ƒZe3e5e7¡e< ?¡dS)>> 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 ". 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 ") >>> s.quit() éN)Ú body_encodeÚ 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ú/usr/lib/python3.7/smtplib.pyrGsc@seZdZdZdS)ÚSMTPNotSupportedErrorzÌ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. N)rrrrrrrrrJsrc@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)rrrrrrrrrQsc@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__bszSMTPResponseException.__init__N)rrrrrrrrrrYsc@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|_dS)N)rrÚsenderr)rrrrrrrrnszSMTPSenderRefused.__init__N)rrrrrrrrrrgsc@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|_dS)N)Ú recipientsr)rrrrrr|szSMTPRecipientsRefused.__init__N)rrrrrrrrrrtsc@seZdZdZdS)rz'The SMTP server didn't accept the data.N)rrrrrrrrrsc@seZdZdZdS)r z&Error during connection establishment.N)rrrrrrrrr „sc@seZdZdZdS)r z"The server refused our HELO reply.N)rrrrrrrrr ‡sc@seZdZdZdS)r zvAuthentication error. Most probably the server didn't accept the username/password combination provided. N)rrrrrrrrr ŠscCs>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 ú)ÚemailÚutilsÚ parseaddrÚstripÚ startswith)Ú addrstringÚ displaynameÚaddrrrrr ‘s  cCs$tj |¡\}}||fdkr |S|S)N)r r )r"r#r$)r'r(r)rrrÚ _addr_onlyžs r*c Cst ddt dt|¡¡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)))ÚreÚsubÚCRLF)Údatarrrr ¦scCst dd|¡S)Ns(?m)^\.s..)r+r,)ZbindatarrrÚ_quote_periods¯sr/cCst dt|¡S)Nz(?:\r\n|\n|\r(?!\n)))r+r,r-)r.rrrÚ _fix_eols²sr0FTc@sveZdZdZdZdZdZdZdZdZ e Z ddde j dfdd„Zdd „Zd d „Zd d „Zdd„Zdd„ZdNdd„Zdd„ZdOdd„Zdd„ZdPdd„ZdQdd„ZdRdd „Zd!d"„ZdSd#d$„Zd%d&„Zd'd(„Zd)d*„ZdTd,d-„Z dUd.d/„Z!d0d1„Z"d2d3„Z#e#Z$d4d5„Z%d6d7„Z&d8d9œd:d;„Z'dVdd?„Z)dXd@dA„Z*d8d9œdBdC„Z+dYdDdE„Z,dZdFdG„Z-d[dHdI„Z.dJdK„Z/dLdM„Z0dS)\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|_||_|rL| ||¡\}}|dkrL| ¡t||ƒ‚|dk r\||_nPt   ¡}d|krt||_n8d} yt   t   ¡¡} Wnt j k 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. ÚasciiéÜNÚ.z 127.0.0.1z[%s])Ú_hostÚtimeoutÚesmtp_featuresÚcommand_encodingÚsource_addressÚconnectÚcloser Úlocal_hostnameÚsocketZgetfqdnZ gethostbynameZ gethostnameZgaierror) rÚhostÚportr<r6r9rrZfqdnr)rrrrâs* z SMTP.__init__cCs|S)Nr)rrrrÚ __enter__szSMTP.__enter__cGsNz>y$| d¡\}}|dkr$t||ƒ‚Wntk r:YnXWd| ¡XdS)NZQUITéÝ)Údocmdrrr;)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)rrErrrÚset_debuglevelszSMTP.set_debuglevelcGs@|jdkr,ttj ¡ ¡f|ždtjiŽnt|dtjiŽdS)NéÚfile)rEÚprintÚdatetimeZnowZtimeÚsysÚstderr)rrrrrÚ _print_debug's "zSMTP._print_debugcCs2|jdkr| d||f|j¡t ||f||j¡S)Nrz connect: to)rErMr9r=Úcreate_connection)rr>r?r6rrrÚ _get_socket-s  zSMTP._get_socketÚ localhostcCsæ|r ||_|s|| d¡| d¡kr|| d¡}|dkr||d|…||dd…}}y t|ƒ}Wntk rztdƒ‚YnX|s†|j}|jdkr | d||f¡|  |||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. ú:rNrGznonnumeric portzconnect:)r9ÚfindÚrfindÚintÚ ValueErrorÚOSErrorÚ default_portrErMrOr6ÚsockrHÚgetreplyÚrepr)rr>r?r9Úirrrrrr:5s(      z SMTP.connectcCs„|jdkr| dt|ƒ¡t|dƒrx|jrxt|tƒr@| |j¡}y|j  |¡Wq€t k rt|  ¡t dƒ‚Yq€Xnt dƒ‚dS)zSend `s' to the server.rzsend:rXzServer not connectedzplease run connect() firstN) rErMrZÚhasattrrXÚ isinstanceÚstrÚencoder8ZsendallrVr;r)rÚsrrrÚsendWs   z SMTP.sendcCs2|dkrd|tf}nd||tf}| |¡dS)zSend a command to the server.r z%s%sz%s %s%sN)r-ra)rÚcmdrr^rrrÚputcmdisz SMTP.putcmdc CsPg}|jdkr|j d¡|_xy|j td¡}Wn:tk rn}z| ¡tdt|ƒƒ‚Wdd}~XYnX|s„| ¡tdƒ‚|j dkrž|  dt |ƒ¡t |ƒtkr¼| ¡t dd ƒ‚| |d d… d ¡¡|dd …}y t|ƒ}Wntk rd }PYnX|d d …dkr Pq Wd |¡}|j dkrH|  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ÚrbrGz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:iôzLine too long.és ééÿÿÿÿó-ó zreply: retcode (%s); Msg: %a)rHrXZmakefileÚreadlineÚ_MAXLINErVr;rr^rErMrZÚlenrÚappendr%rTrUÚjoin)rÚrespÚlineÚerZerrcodeÚerrmsgrrrrYqs>         z SMTP.getreplycCs| ||¡| ¡S)z-Send a command, and return its response code.)rcrY)rrbrrrrrB¢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)rcr<rYÚ helo_resp)rÚnamerrrrrrs¨s z SMTP.heloc CsLi|_| |j|p|j¡| ¡\}}|dkrJt|ƒdkrJ| ¡tdƒ‚||_|dkr`||fSd|_ t |jt ƒs€t t |jƒƒ‚|j d¡ d¡}|d=xª|D]¢}t |¡}|rØ|j dd ¡d | d¡d|jd<qžt d |¡}|rž| d ¡ ¡}|j| d ¡d … ¡} |dkr6|j |d ¡d | |j|<qž| |j|<qžW||fS)zx SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. rgrzServer not connectedéúrGzlatin-1Ú Úauthr ú z((?P[A-Za-z0-9][A-Za-z0-9\-]*) ?ÚfeatureN)r7rcÚehlo_msgr<rYrlr;rÚ ehlo_respÚ does_esmtpr]ÚbytesÚAssertionErrorrZÚdecodeÚsplitÚ OLDSTYLE_AUTHÚmatchÚgetÚgroupsr+ÚgroupÚlowerÚstringÚendr%) rrurrroÚeachZ auth_matchÚmrzZparamsrrrr1²s4   &  z SMTP.ehlocCs| ¡|jkS)z7Does the server support a given SMTP service extension?)r‡r7)rZoptrrrÚhas_extnåsz SMTP.has_extncCs| d|¡| ¡dS)z;SMTP 'help' command. Returns help text from server.ÚhelprG)rcrY)rrrrrrés z SMTP.helpcCsd|_| d¡S)z&SMTP 'rset' command -- resets session.r2Úrset)r8rB)rrrrrŽïsz SMTP.rsetcCs&y | ¡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 | d¡S)z-SMTP 'noop' command -- doesn't do anything :>Únoop)rB)rrrrrsz 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ú szSMTP.mail..r‘zutf-8z SMTPUTF8 not supported by serverryÚmailz FROM:%s%s) r}ÚanyrŒr8rrnrcr rY)rrÚoptionsÚ optionlistrrrr•s   z SMTP.mailcCs<d}|r|jrdd |¡}| ddt|ƒ|f¡| ¡S)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r ryÚrcptzTO:%s%s)r}rnrcr rY)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. r.rzdata:ibr2éþÿÿÿNó.) rcrYrErMrr]r^r0r_r/ÚbCRLFra)rrrÚreplÚqrrrr.!s"         z SMTP.datacCs| dt|ƒ¡| ¡S)z5SMTP 'verify' command -- checks for address validity.Úvrfy)rcr*rY)rÚaddressrrrÚverify>sz SMTP.verifycCs| dt|ƒ¡| ¡S)z.SMTP 'expn' command -- expands a mailing list.Úexpn)rcr*rY)rr rrrr¢Esz SMTP.expncCsb|jdkr^|jdkr^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+)rtr|r1rsr )rrrorrrÚehlo_or_helo_if_neededLs  zSMTP.ehlo_or_helo_if_neededT)Úinitial_response_okc Cs®| ¡}|r|ƒnd}|dk rJt| d¡dd}| d|d|¡\}}n| d|¡\}}|dkrt |¡}t||ƒ d¡dd}| |¡\}}|dkr ||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. Nr2r )ZeolZAUTHryiN)éëi÷)ÚupperÚ encode_base64r_rBÚbase64Z decodebytesr ) rZ mechanismZ authobjectr¥Zinitial_responseZresponserroÚ challengerrrrx]s z SMTP.authcCs0|dkr dS|jdt |j d¡|d¡ ¡S)zh Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.Nryr2Zmd5)ÚuserÚhmacZHMACÚpasswordr_Z 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­)rrªrrrÚ auth_plainszSMTP.auth_plaincCs|dkr|jS|jSdS)ze Authobject to use with LOGIN authentication. Requires self.user and self.password to be set.N)r«r­)rrªrrrÚ auth_login’szSMTP.auth_loginc sÞ| ¡| d¡stdƒ‚|jd ¡‰dddg}‡fdd„|Dƒ}|sPtdƒ‚|||_|_xv|D]n}d | ¡  d d ¡}y.|j |t ||ƒ|d \}} |d kr¨|| fSWqdt k rÐ} z| } Wdd} ~ XYqdXqdW| ‚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. rxz,SMTP AUTH extension not supported by server.zCRAM-MD5ZPLAINZLOGINcsg|]}|ˆkr|‘qSrr)r’rx)Úadvertised_authlistrrú ÃszSMTP.login..z(No suitable authentication method found.Zauth_ú-Ú_)r¥)r¦i÷N) r¤rŒrr7rrr«r­r‡ÚreplacerxÚgetattrr ) rr«r­r¥Zpreferred_authsZauthlistZ authmethodZ method_namerrorqZlast_exceptionr)r±rÚloginšs*      z SMTP.logincCsî| ¡| d¡stdƒ‚| d¡\}}|dkrÜts>> 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. r2Úsizezsize=%drvi¥éû)r¤r]r^r0r_r}rŒrmrlr•r;rrr™rr.r) rÚ from_addrÚto_addrsrÚ mail_optionsÚ rcpt_optionsZ esmtp_optsZoptionrroZsenderrsrŠrrrÚsendmailsF@             z SMTP.sendmailc Csœ| ¡| d¡}|dkr d}nt|ƒdkr2d}ntdƒ‚|dkr||d|krZ||dn ||d}tj |g¡d d}|dkrÆd d „||d ||d ||dfDƒ}dd „tj |¡Dƒ}t |¡} | d =| d=d} yd |f|•¡  d¡Wn.t k r(|  d¡s t dƒ‚d} YnXt  ¡R} | r^tjj| |jjddd} |d˜}n tj | ¡} | j| dd|  ¡} WdQRX| ||| ||¡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. z Resent-DateNr rGzResent-z0message has more than one 'Resent-' header blockZSenderÚFromrcSsg|]}|dk r|‘qS)Nr)r’Úfrrrr²ªsz%SMTP.send_message..ÚToZBccZCccSsg|] }|d‘qS)rGr)r’Úarrrr²®sz Resent-BccFr2r‘z”One or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)Úutf8)ÚpolicyÚSMTPUTF8ú BODY=8BITMIMEz )Úlinesep)rÓrÔ)r¤Zget_allrlrUr"r#Z getaddressesÚcopyrnr_ÚUnicodeEncodeErrorrŒrÚioÚBytesIOÚ generatorZBytesGeneratorrÒZcloneZflattenÚgetvaluerÌ)rrrÈrÉrÊrËZresentZ header_prefixZ addr_fieldsZmsg_copyZ internationalZbytesmsgÚgZflatmsgrrrÚ send_message|sJ           zSMTP.send_messagecCs<z|j}d|_|r| ¡Wd|j}d|_|r6| ¡XdS)z(Close the connection to the SMTP server.N)rHr;rX)rrHrXrrrr;És z SMTP.closecCs.| d¡}d|_|_i|_d|_| ¡|S)zTerminate the SMTP session.ÚquitNF)rBr|rtr7r}r;)rZresrrrrÞÖs   z SMTP.quit)rPrN)r )r )r )r )r )r)r)N)N)N)NNN)rr)NNrr)1rrrrrErHrtr{r|r}Ú SMTP_PORTrWr=Ú_GLOBAL_DEFAULT_TIMEOUTrr@rDrFrMrOr:rarcrYrBrsr1rŒrrŽrrr•r™r.r¡rŸr¢r¤rxr®r¯r°r·r¸rÌrÝr;rÞrrrrr½s^ -   " 1  3    '  B 8 g L c@s8eZdZdZeZdddddejddfdd„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 rtdƒ‚|dk r0|dk r0tdƒ‚|dk s@|dk rVddl} |  dtd¡||_||_|dkrxtj||d}||_t   ||||||¡dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadr¹)rºr») rUr¿rÀrÁr»rºrÂrÃrÅrr) rr>r?r<r»rºr6r9rÅr¿rrrròs zSMTP_SSL.__init__cCsD|jdkr| d||f¡t ||f||j¡}|jj||jd}|S)Nrzconnect:)r¼)rErMr=rNr9rÅrÄr5)rr>r?r6Z new_socketrrrrO s   zSMTP_SSL._get_socket) rrrrÚ SMTP_SSL_PORTrWr=ràrrOrrrrráâs ráiÓc@s0eZdZdZdZdeddfdd„Zd d 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 NcCstj|||||ddS)zInitialize a new instance.)r<r9N)rr)rr>r?r<r9rrrr)s z LMTP.__init__rPrcCs´|ddkrtj||||dSy(t tjtj¡|_d|_|j |¡WnBtk rˆ|jdkrl|  d|¡|jr||j  ¡d|_‚YnX|  ¡\}}|jdkr¬|  d|¡||fS)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.rú/)r9Nz connect fail:zconnect:) rr:r=ZAF_UNIXZ SOCK_STREAMrXrHrVrErMr;rY)rr>r?r9rrrrrr:/s"       z LMTP.connect)rPrN)rrrrr{Ú LMTP_PORTrr:rrrrrãs   rãÚ__main__cCs(tj |d¡tj ¡tj ¡ ¡S)Nz: )rKÚstdoutÚwriteÚflushÚstdinrjr%)ÚpromptrrrrëIs rërÍrÏú,zEnter message, end with ^D:r zMessage length is %drPrG)@rr=rØr+Z email.utilsr"Z email.messageZemail.generatorr©r¬rÖrJrKZemail.base64mimerr¨Ú__all__rßrâr-rœrkÚcompileÚIr‚rVrrrrrrrr r r r r*r r/r0rÂÚ ImportErrorr½rrármrårãrrëZfromaddrrZtoaddrsrIrrêrjrprlZserverrFrÌrÞrrrrÚ!sŒ         )0 /