QfdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZgdZdZdZdZdZd Zd Zej.d ej0ZGd d eZGddeZGddeZGddeZGddeZGddeZ GddeZ!GddeZ"GddeZ#GddeZ$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(rd/Z3e3d0Z4e3d1jkd2Z6e7d3d4Z8e jrjuxZ;r"e8e;zZ8e jrjuxZ;r"e7d5e>> 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) SMTPExceptionSMTPNotSupportedErrorSMTPServerDisconnectedSMTPResponseExceptionSMTPSenderRefusedSMTPRecipientsRefused SMTPDataErrorSMTPConnectError SMTPHeloErrorSMTPAuthenticationError quoteaddr quotedataSMTPi s i z auth=(.*)ceZdZdZy)rz4Base class for all exceptions raised by this module.N__name__ __module__ __qualname____doc__./opt/alt/python312/lib64/python3.12/smtplib.pyrrHs>rrceZdZdZy)rzThe 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. NrrrrrrKrrceZdZdZy)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. NrrrrrrRsrrceZdZdZdZy)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. c2||_||_||f|_yN) smtp_code smtp_errorargs)selfcodemsgs r__init__zSMTPResponseException.__init__cs3K rNrrrrr)rrrrrZs  rrceZdZdZdZy)rzSender address refused. In addition to the attributes set by on all SMTPResponseException exceptions, this sets `sender' to the string that the SMTP refused. cB||_||_||_|||f|_yr")r#r$senderr%)r&r'r(r-s rr)zSMTPSenderRefused.__init__os% 3' rNr*rrrrrhs  (rrceZdZdZdZy)r zAll 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 ceZdZdZy)r z'The SMTP server didn't accept the data.Nrrrrr r s1rr ceZdZdZy)r z&Error during connection establishment.Nrrrrr r s0rr ceZdZdZy)r z"The server refused our HELO reply.Nrrrrr r s,rr ceZdZdZy)r zvAuthentication error. Most probably the server didn't accept the username/password combination provided. Nrrrrr r rrr ctjj|\}}||fdk(r&|jj dr|Sd|zSd|zS)zQuote a subset of the email addresses defined by RFC 821. Should be able to handle anything email.utils.parseaddr can handle. r7)emailutils parseaddrstrip startswith addrstring displaynameaddrs rrrs\  --j9KTh&     ( ( -  "" D=rc\tjj|\}}||fdk(r|S|S)Nr6)r9r:r;r>s r _addr_onlyrCs3 --j9KTh& Krc btjddtjdt|S)zQuote 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))resubCRLFdatas rrrs* 66*d &d3 55rc0tjdd|S)Ns(?m)^\.s..)rGrH)bindatas r_quote_periodsrNs 66+ug ..rc8tjdt|S)NrErFrJs r _fix_eolsrPs FF*D$ 77rTFcTeZdZdZdZdZdZdZdZdZ dZ e Z ddde jdfdZdZd Zd Zd Zd Zd,d ZdZd-dZdZd-dZd-dZd-dZdZd-dZdZdZdZ d.dZ!d.dZ"dZ#dZ$e$Z%dZ&dZ'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)2raThis 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. rNehloFr7c||_||_i|_d|_||_d|_|r6|j ||\}}|dk7r|jt|||||_ 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. asciirN.z 127.0.0.1z[%s])_hosttimeoutesmtp_featurescommand_encodingsource_address_auth_challenge_countconnectcloser local_hostnamesocketgetfqdn gethostbyname gethostnamegaierror) r&hostportr_rXr[r'r(fqdnrAs rr)z SMTP.__init__s$    ',%&" ,,tT2KT3s{ &tS11  %"0D  >>#Dd{&*##!//0B0B0DED'-tm#s'CCCc|Sr"rr&s r __enter__zSMTP.__enter__s rc |jd\}}|dk7r t|| |jy#t$rYwxYw#|jwxYw)NQUIT)docmdrrr^)r&r%r'messages r__exit__z SMTP.__exit__s]  JJv.MD's{+D':: JJL&    JJLs&%9A AAAAAc||_y)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)r&rrs rset_debuglevelzSMTP.set_debuglevel"s %rc|jdkDrHttjjj g|dt j iyt|dt j iy)Nfile)rrprintdatetimenowtimesysstderrr&r%s r _print_debugzSMTP._print_debug+sM ??Q  (##'')..0 I4 Icjj I 4 )cjj )rc| |s td|jdkDr|jd||f|jt j ||f||jS)N0Non-blocking socket (timeout=0) is not supportedrz connect: to) ValueErrorrrr~r[r`create_connection)r&rerfrXs r _get_socketzSMTP._get_socket1sd  wOP P ??Q    mdD\4;N;N O''t g(,(;(;= =rc |r||_|sR|jd|jdk(r/|jd}|dk\r|d|||dzd}} t|}|s |j }tjd||||j|||j|_ d|_ |j\}}|jdkDr|jdt!|||fS#t$r t dwxYw)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.connectconnect:)r[findrfindintrOSError default_portr{auditrrXsockrvgetreplyrrr~repr)r&rerfr[ir'r(s rr]z SMTP.connect;s "0D 34::c?: 3AAv!"1XtAEF|d5t9D$$D #T46$$T4>  mmo s ??Q    j$s) 4c{"5!"3445s  C..Dc|jdkDr|jdt||jr_t |t r|j |j}tjd|| |jj|ytd#t$r|jtdwxYw)zSend `s' to the server.rzsend:z smtplib.sendServer not connectedzplease run connect() firstN)rrr~rr isinstancestrencoderZr{rsendallrr^r)r&ss rsendz SMTP.send\s ??Q    gtAw / 99!S!HHT223 IIndA . E !!!$ ))EF F  E ,-CDD Es :B!!%Cc|dk(r|}n|d|}d|vsd|vr0|jddjdd}td||j|ty) zSend a command to the server.r7   z\nz\rz=command and arguments contain prohibited newline characters: N)replacerrrI)r&cmdr%rs rputcmdz SMTP.putcmdosu 2:A%qA 19  $&..tU;AOPQsS  QCv,rcg}|j |jjd|_ |jjtdz}|s|j td|jdkDr|jdt|t|tkDr|j tdd |j|d djd |dd } t!|}|d d dk7rndj%|}|jdkDr|jd|d|||fS#t $r,}|j tdt|zd}~wwxYw#t"$rd }YwxYw)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. Nrbruz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:izLine too long.s - zreply: retcode (z); Msg: )rvrmakefilereadline_MAXLINErr^rrrrr~rlenrappendr<rrjoin)r&resplineer'errcodeerrmsgs rrz SMTP.getreply|sz 99  **40DI 7yy))(Q,7  ,-MNN"!!(DJ74y8# +C1ABB KKQRz2 38D d) AayD 58D! ??Q    P Q9 7 ,-O/21v.677 7$  s)"E1 E9 E6 'E11E69 FFcF|j|||jS)z-Send a command, and return its response code.rr)r&rr%s rrnz SMTP.docmds 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)rr_r helo_resp)r&namer'r(s rrz SMTP.helos= FD7D$7$78mmo sc{rci|_|j|j|xs |j|j \}}|dk(r)t |dk(r|j td||_|dk7r||fSd|_ |jjdjd}|d=|D]}tj|}|rB|jjdd d z|jddz|jd<]t!jd |}|sv|j#d j%}|j&|j)d d j+} |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. rrrTzlatin-1rauthr7rz((?P[A-Za-z0-9][A-Za-z0-9\-]*) ?featureN)rYrehlo_msgr_rrr^r ehlo_resp does_esmtpdecodesplit OLDSTYLE_AUTHmatchgetgroupsrGgrouplowerstringendr<) r&rr'r(reach auth_matchmrparamss rrRz SMTP.ehlos ! DMM4#>4+>+>?mmo s 2:#c(a- JJL()?@ @ 3;#; ~~$$Y/55d; GD',,T2J.2.A.A.E.Efb.Q/ * 1 1! 4Q 7/8##F+ DdKA''),224!%% "2"34::<f$373F3F3J3J7TV3W!4"$*4+D''04:D''056c{rc:|j|jvS)z7Does the server support a given SMTP service extension?)rrY)r&opts rhas_extnz SMTP.has_extnsyy{d1111rcL|jd||jdS)z;SMTP 'help' command. Returns help text from server.helprurr}s rrz SMTP.helps# FD!}}q!!rc2d|_|jdS)z&SMTP 'rset' command -- resets session.rTrset)rZrnris rrz SMTP.rsets 'zz&!!rcD |jy#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)rrris r_rsetz SMTP._rsets"  IIK%   s  c$|jdS)z-SMTP 'noop' command -- doesn't do anything :>noop)rnris rrz SMTP.noop szz&!!rcd}|rV|jrJtd|Dr$|jdrd|_n t dddj |z}|j ddt|||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. r7c3BK|]}|jdk(yw)smtputf8N)r).0xs r zSMTP.mail..s:'Q1779j('srzutf-8z SMTPUTF8 not supported by serverrmailzFROM:) ranyrrZrrrrr)r&r-options optionlists rrz SMTP.mails{ t:'::==,,3D)/:<<sxx00J F9V+> !dnn&<499;q>0S0#yy{ tt*s*'d33+1'= !rTinitial_response_okcH|j}|r|nd}|?t|jdd}|jd|dz|z\}}d|_n|jd|\}}d|_|d k(r|xjdz c_t j |}t||jdd}|j|\}}|jtkDrtd t||fz|d k(r|d vr||fSt||) 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 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)eolAUTHrruriNz4Server AUTH mechanism infinite loop. Last response: i) upper encode_base64rrnr\base64 decodebytes _MAXCHALLENGErrr ) r& mechanism authobjectrinitial_responseresponser'r challenges rrz SMTP.authhs-,OO% ,?JLT  '$%5%<%99 == rc|j|jds td|jdj }gd}|Dcgc]}||vr| }}|s t d||c|_|_|D]Q}d|jjddz} |j|t|| |\} } | d vr| | fcSS 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. rz,SMTP AUTH extension not supported by server.)zCRAM-MD5PLAINLOGINz(No suitable authentication method found.auth_-_rrN) rrrrYrrr r rrrgetattrr )r&r r radvertised_authlistpreferred_authsrauthlist authmethod method_namer'rrlast_exceptions rloginz SMTP.logins*8 ##%}}V$'>@ @#11&9??A9&54_T22_4 JK K $(  4="J!J$4$4$6$>$>sC$HHK ##yyk :(; ) = t :% $<'&#/4&+ #!" #s C&(C C/#C**C/)contextc|j|jds td|jd\}}|dk(rzts t d|t j}|j|j|j|_ d|_ d|_ d|_ i|_d|_||fSt!||) 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 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 PythonNserver_hostnameF)rrrrn _have_ssl RuntimeErrorssl_create_stdlib_context wrap_socketrrWrvrrrYrr)r&r%rreplys rr'z SMTP.starttlss" ##%}}Z('=? ? :. u 3;"#KLL446++DII<@JJ,HDIDI "DN!DN"$D #DO e}(e4 4rcz|jg}t|trt|j d}|j rF|j dr|jdt|z|D]}|j||j||\}} |dk7r3|dk(r|jn|jt|| |i} t|tr|g}|D]H} |j| |\}} |dk7r |dk7r|| f| | <|dk(s/|jt| t| t|k(r|jt| |j|\}} |dk7r2|dk(r|jn|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. rTsizezsize=%dri)rrrrPrrrrrrr^rrrr rKr ) r& from_addrto_addrsr( mail_options rcpt_options esmtp_optsoptionr'rsenderrsrs rsendmailz SMTP.sendmails@ ##% c3 C.''0C ??}}V$!!)c#h"67&!!&)'yyJ7 t 3;s{  #D$ : : h $ zHD99T<8LT4 $#+"&s{ +H55  x=CM ) JJL'1 1yy~ t 3;s{  d+ +rc0|j|jd}|d}nt|dk(rd}n td|=|dz|vr||dzn||dz}tj j |gd d}|U||d z||d z||d zfDcgc]}||} }tj j | D cgc]} | d }} tj|} | d =| d =d} dj|g|jdtj5} | rEtjj!| |j"j%d}g|dd}ntjj!| }|j'| d| j)}ddd|j+||||Scc}wcc} w#t$r!|jds tdd} YwxYw#1swYUxYw)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-DateNr7ruzResent-z0message has more than one 'Resent-' header blockSenderFromrToBccCcz Resent-BccFrTrzOne or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)utf8)policySMTPUTF8z BODY=8BITMIMEr)linesep)rget_allrrr9r: getaddressescopyrrUnicodeEncodeErrorrrioBytesIO generatorBytesGeneratorrCcloneflattengetvaluer;)r&r(r4r5r6r7resent header_prefixf addr_fieldsamsg_copy internationalbytesmsggflatmsgs r send_messagezSMTP.send_messages]> ##%]+ >M [A %MOP P   -x7C?]X56 #MF$: ;  00)=a@CI  '*=4+?'@'*=5+@'A'*=4+?'@'B-'B m'BK-',kk&>&>{&KL&K!&KHL99S> UO \ "  ! GGY** + 2 27 ;ZZ\XOO22SZZ%5%54%5%@3BKKzK?K OO228< IIhI /'')G}}Y'<)+ +9-M" !==,+KLL!M  !\s+ G G7#G.B H 'H H  Hc |j}d|_|r|j|j}d|_|r|jyy#|j}d|_|r|jwwxYw)z(Close the connection to the SMTP server.N)rvr^r)r&rvrs rr^z SMTP.closesi 99DDI 99DDI 99DDI s %A(A6c|jd}dx|_|_i|_d|_|j |S)zTerminate the SMTP session.quitNF)rnrrrYrr^)r&ress rr^z SMTP.quits;jj *..   r localhostrN)r7)rr")rr)NNrr)2rrrrrrrrvrrrr SMTP_PORTrr`_GLOBAL_DEFAULT_TIMEOUTr)rjrprsr~rr]rrrrnrrRrrrrrrrrKrrrrrrrrr$r'r;r[r^r^rrrrrs& 8J D DIHIJLQt77 $.4`%* =BG&  /b 1f2" " "*: D4"BF.2`I7 !<@@D#'+Z?A fP:>35K+Z rrcLeZdZdZeZdejddddZfdZ 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%cr|tj}||_tj ||||||yr")r-r.r%rr))r&rerfr_rXr[r%s rr)zSMTP_SSL.__init__s7446"DL MM$dNG( *rc|jdkDr|jd||ft| |||}|jj ||j }|S)Nrrr))rrr~superrr%r/rW)r&rerfrX new_socket __class__s rrzSMTP_SSL._get_sockets_"!!*tTl;,T4AJ11*BF**2NJ r)r7rN) rrrr SMTP_SSL_PORTrr`rcr)r __classcell__rjs@rreres1 %  * & > >$($ *  rreicReZdZdZdZdeddejffd Zdfd Z xZ S)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.lhlor7Nc.t||||||y)zInitialize a new instance.)r_r[rXN)rhr))r&rerfr_r[rXrjs rr)z LMTP.__init__ s# tN(6  Irc|ddk7rt||||S|j|js td t jtj tj |_|jtjur%|jj|jd|_ |jj||j\}}|jdkDr|jd|||fS#t$rP|jdkDr|jd||jr|jjd|_wxYw)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.r/)r[Nrz connect fail:r)rhr]rXrr`AF_UNIX SOCK_STREAMrrc settimeoutrvrrrr~r^r)r&rerfr[r'r(rjs rr]z LMTP.connect&s$ 7c>7?4n?M M << #DLLOP P  fnnf6H6HIDI||6#A#AA $$T\\2DI II  d #mmo s ??Q    j# .c{ "!!/48yy !DI   sBDAE+r`) rrrrr LMTP_PORTr`rcr)r]rlrms@rroros1 4HYt $f.L.LI rro__main__ctjj|dztjjtjj j S)Nz: )r{stdoutwriteflushstdinrr<)prompts rr~r~EsD $' yy!!#))++rr>r?,zEnter message, end with ^D:r7zMessage length is %draru)Arr`rJrG email.utilsr9 email.messageemail.generatorrr rHrxr{email.base64mimerr__all__rbrkrIrrrcompileIrrrrrrrr r r r r rrCrrNrPr-r+ ImportErrorrrerrwrorr~fromaddrrtoaddrsrwr(r}rrrserverrsr;r^rrrrs)R   9 -       <. ?G?M]  M   (- ( "M "2)21,1-)-3 5/8Ii i V 4< NN:  /4/h z, f~HTl  %G '( C))$$& &$ &Dj))$$& &$ & 3s8 +, + F ! OOHgs+ KKM#YIs GG#"G#