/snap/core20/2769/usr/lib/python3.8/__pycache__
NameSizeModeActions
abc.cpython-38.pyc53340644editdlrm
aifc.cpython-38.pyc254740644editdlrm
antigravity.cpython-38.pyc7970644editdlrm
argparse.cpython-38.pyc625910644editdlrm
ast.cpython-38.pyc167630644editdlrm
asynchat.cpython-38.pyc68510644editdlrm
asyncore.cpython-38.pyc160280644editdlrm
base64.cpython-38.pyc170710644editdlrm
bdb.cpython-38.pyc249210644editdlrm
binhex.cpython-38.pyc121340644editdlrm
bisect.cpython-38.pyc23540644editdlrm
bz2.cpython-38.pyc114450644editdlrm
calendar.cpython-38.pyc270640644editdlrm
cgi.cpython-38.pyc265440644editdlrm
cgitb.cpython-38.pyc101500644editdlrm
chunk.cpython-38.pyc48390644editdlrm
cmd.cpython-38.pyc126260644editdlrm
code.cpython-38.pyc99130644editdlrm
codecs.cpython-38.pyc339560644editdlrm
codeop.cpython-38.pyc64170644editdlrm
colorsys.cpython-38.pyc32400644editdlrm
compileall.cpython-38.pyc94100644editdlrm
configparser.cpython-38.pyc457180644editdlrm
contextlib.cpython-38.pyc202290644editdlrm
contextvars.cpython-38.pyc2430644editdlrm
copy.cpython-38.pyc69870644editdlrm
copyreg.cpython-38.pyc43180644editdlrm
cProfile.cpython-38.pyc54800644editdlrm
crypt.cpython-38.pyc33870644editdlrm
csv.cpython-38.pyc119100644editdlrm
dataclasses.cpython-38.pyc236530644editdlrm
datetime.cpython-38.pyc571730644editdlrm
decimal.cpython-38.pyc3590644editdlrm
difflib.cpython-38.pyc594380644editdlrm
dis.cpython-38.pyc158080644editdlrm
doctest.cpython-38.pyc759740644editdlrm
dummy_threading.cpython-38.pyc11100644editdlrm
enum.cpython-38.pyc259620644editdlrm
filecmp.cpython-38.pyc84270644editdlrm
fileinput.cpython-38.pyc133730644editdlrm
fnmatch.cpython-38.pyc33550644editdlrm
formatter.cpython-38.pyc175450644editdlrm
fractions.cpython-38.pyc187390644editdlrm
ftplib.cpython-38.pyc280070644editdlrm
functools.cpython-38.pyc279010644editdlrm
genericpath.cpython-38.pyc40010644editdlrm
getopt.cpython-38.pyc62710644editdlrm
getpass.cpython-38.pyc41780644editdlrm
gettext.cpython-38.pyc180000644editdlrm
glob.cpython-38.pyc43430644editdlrm
gzip.cpython-38.pyc181840644editdlrm
hashlib.cpython-38.pyc67270644editdlrm
heapq.cpython-38.pyc140700644editdlrm
hmac.cpython-38.pyc63880644editdlrm
imaplib.cpython-38.pyc414640644editdlrm
imghdr.cpython-38.pyc41180644editdlrm
imp.cpython-38.pyc98090644editdlrm
inspect.cpython-38.pyc805930644editdlrm
io.cpython-38.pyc34540644editdlrm
ipaddress.cpython-38.pyc628290644editdlrm
keyword.cpython-38.pyc9980644editdlrm
linecache.cpython-38.pyc38670644editdlrm
locale.cpython-38.pyc346740644editdlrm
lzma.cpython-38.pyc120180644editdlrm
mailbox.cpython-38.pyc602640644editdlrm
mailcap.cpython-38.pyc72060644editdlrm
mimetypes.cpython-38.pyc160310644editdlrm
modulefinder.cpython-38.pyc161150644editdlrm
netrc.cpython-38.pyc37770644editdlrm
nntplib.cpython-38.pyc339740644editdlrm
ntpath.cpython-38.pyc140910644editdlrm
nturl2path.cpython-38.pyc17440644editdlrm
numbers.cpython-38.pyc122020644editdlrm
opcode.cpython-38.pyc54200644editdlrm
operator.cpython-38.pyc136910644editdlrm
optparse.cpython-38.pyc480570644editdlrm
os.cpython-38.pyc313970644editdlrm
pathlib.cpython-38.pyc442090644editdlrm
pdb.cpython-38.pyc472260644editdlrm
pickle.cpython-38.pyc469080644editdlrm
pickletools.cpython-38.pyc672040644editdlrm
pipes.cpython-38.pyc77950644editdlrm
pkgutil.cpython-38.pyc163090644editdlrm
platform.cpython-38.pyc243260644editdlrm
plistlib.cpython-38.pyc273740644editdlrm
poplib.cpython-38.pyc135560644editdlrm
posixpath.cpython-38.pyc104610644editdlrm
pprint.cpython-38.pyc162810644editdlrm
profile.cpython-38.pyc147580644editdlrm
pstats.cpython-38.pyc220660644editdlrm
pty.cpython-38.pyc39550644editdlrm
pyclbr.cpython-38.pyc104510644editdlrm
pydoc.cpython-38.pyc836460644editdlrm
py_compile.cpython-38.pyc73520644editdlrm
queue.cpython-38.pyc106260644editdlrm
quopri.cpython-38.pyc57480644editdlrm
random.cpython-38.pyc201080644editdlrm
re.cpython-38.pyc144220644editdlrm
reprlib.cpython-38.pyc53030644editdlrm
rlcompleter.cpython-38.pyc57550644editdlrm
runpy.cpython-38.pyc81810644editdlrm
sched.cpython-38.pyc65320644editdlrm
secrets.cpython-38.pyc21900644editdlrm
selectors.cpython-38.pyc169350644editdlrm
shelve.cpython-38.pyc94900644editdlrm
shlex.cpython-38.pyc75360644editdlrm
shutil.cpython-38.pyc372190644editdlrm
signal.cpython-38.pyc28430644editdlrm
site.cpython-38.pyc171680644editdlrm
sitecustomize.cpython-38.pyc2200644editdlrm
smtpd.cpython-38.pyc264630644editdlrm
smtplib.cpython-38.pyc355320644editdlrm
sndhdr.cpython-38.pyc69890644editdlrm
socket.cpython-38.pyc277870644editdlrm
socketserver.cpython-38.pyc253610644editdlrm
sre_compile.cpython-38.pyc151420644editdlrm
sre_constants.cpython-38.pyc63590644editdlrm
sre_parse.cpython-38.pyc216470644editdlrm
ssl.cpython-38.pyc450370644editdlrm
stat.cpython-38.pyc43720644editdlrm
statistics.cpython-38.pyc336530644editdlrm
string.cpython-38.pyc73000644editdlrm
stringprep.cpython-38.pyc110170644editdlrm
struct.cpython-38.pyc3300644editdlrm
subprocess.cpython-38.pyc419670644editdlrm
sunau.cpython-38.pyc170800644editdlrm
symbol.cpython-38.pyc24040644editdlrm
symtable.cpython-38.pyc113220644editdlrm
sysconfig.cpython-38.pyc158370644editdlrm
tabnanny.cpython-38.pyc70300644editdlrm
tarfile.cpython-38.pyc630430644editdlrm
telnetlib.cpython-38.pyc182370644editdlrm
tempfile.cpython-38.pyc266530644editdlrm
textwrap.cpython-38.pyc135190644editdlrm
this.cpython-38.pyc12610644editdlrm
threading.cpython-38.pyc399760644editdlrm
timeit.cpython-38.pyc117770644editdlrm
token.cpython-38.pyc24850644editdlrm
tokenize.cpython-38.pyc171600644editdlrm
trace.cpython-38.pyc200260644editdlrm
traceback.cpython-38.pyc199380644editdlrm
tracemalloc.cpython-38.pyc173630644editdlrm
tty.cpython-38.pyc10760644editdlrm
turtle.cpython-38.pyc1300220644editdlrm
types.cpython-38.pyc91770644editdlrm
typing.cpython-38.pyc624200644editdlrm
uu.cpython-38.pyc36050644editdlrm
uuid.cpython-38.pyc236830644editdlrm
warnings.cpython-38.pyc136520644editdlrm
wave.cpython-38.pyc181490644editdlrm
weakref.cpython-38.pyc195180644editdlrm
webbrowser.cpython-38.pyc171200644editdlrm
xdrlib.cpython-38.pyc82210644editdlrm
zipapp.cpython-38.pyc58540644editdlrm
zipfile.cpython-38.pyc593360644editdlrm
zipimport.cpython-38.pyc172750644editdlrm
_bootlocale.cpython-38.pyc12430644editdlrm
_collections_abc.cpython-38.pyc287410644editdlrm
_compat_pickle.cpython-38.pyc55010644editdlrm
_compression.cpython-38.pyc41460644editdlrm
_dummy_thread.cpython-38.pyc60370644editdlrm
_markupbase.cpython-38.pyc77900644editdlrm
_osx_support.cpython-38.pyc115930644editdlrm
_pydecimal.cpython-38.pyc1607350644editdlrm
_pyio.cpython-38.pyc740790644editdlrm
_py_abc.cpython-38.pyc46700644editdlrm
_sitebuiltins.cpython-38.pyc34810644editdlrm
_strptime.cpython-38.pyc160440644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-38.pyc211210644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-38.pyc211150644editdlrm
_threading_local.cpython-38.pyc64460644editdlrm
_weakrefset.cpython-38.pyc76000644editdlrm
__future__.cpython-38.pyc41580644editdlrm
__phello__.foo.cpython-38.pyc1270644editdlrm
Edit: /snap/core20/2769/usr/lib/python3.8/__pycache__/smtplib.cpython-38.pyc (35532B)
U yi @srdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZdddddd d d d d dddg ZdZdZdZdZdZdZedejZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZ Gdd d eZ!Gdd d eZ"Gd d d eZ#Gd!d d eZ$d"dZ%d#d$Z&d%dZ'd&d'Z(d(d)Z)z ddl*Z*Wne+k rd*Z,YnXd+Z,Gd,ddZ-e,rGd-d.d.e-Z.e/d.d/Z0Gd0d1d1e-Z1e2d2krnd3d4Z3e3d5Z4e3d65d7Z6e7d8d9Z8e j9:Z;e;s*q6e8e;Z8qe7d:ed<e=?e4e6e8e=@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 ". 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=(.*)c@seZdZdZdS)rz4Base class for all exceptions raised by this module.N__name__ __module__ __qualname____doc__rr/usr/lib/python3.8/smtplib.pyrHsc@seZdZdZdS)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. NrrrrrrKsc@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. NrrrrrrRsc@seZdZdZddZdS)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|_dSN) smtp_code smtp_errorargs)selfcodemsgrrr__init__cszSMTPResponseException.__init__Nrrrrr!rrrrrZsc@seZdZdZddZdS)rzSender 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|_dSr)rrsenderr)rrr r#rrrr!oszSMTPSenderRefused.__init__Nr"rrrrrhsc@seZdZdZddZdS)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|_dSr) recipientsr)rr$rrrr!}szSMTPRecipientsRefused.__init__Nr"rrrrrusc@seZdZdZdS)r z'The SMTP server didn't accept the data.Nrrrrrr sc@seZdZdZdS)r z&Error during connection establishment.Nrrrrrr sc@seZdZdZdS)r z"The server refused our HELO reply.Nrrrrrr sc@seZdZdZdS)r zvAuthentication error. Most probably the server didn't accept the username/password combination provided. Nrrrrrr scCs>tj|\}}||fdkr6|dr.|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. r&)emailutils parseaddrstrip startswithZ addrstringZ displaynameaddrrrrr s  cCs$tj|\}}||fdkr |S|S)Nr%)r(r)r*r-rrr _addr_onlys r/c Cstddtdt|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))resubCRLFdatarrrrs cCstdd|S)Ns(?m)^\.s..)r2r3)Zbindatarrr_quote_periodssr7cCstdt|S)Nr0r1r5rrr _fix_eolssr8FTc@szeZdZdZdZdZdZdZdZdZ dZ e Z ddde jdfddZdd Zd d Zd d ZddZddZdNddZddZdOddZddZdPddZdQddZdRdd Zd!d"ZdSd#d$Zd%d&Zd'd(Zd)d*Z dTd,d-Z!dUd.d/Z"d0d1Z#d2d3Z$e$Z%d4d5Z&d6d7Z'd8d9d:d;Z(dVdd?Z*dXd@dAZ+d8d9dBdCZ,dYdDdEZ-dZdFdGZ.d[dHdIZ/dJdKZ0dLdMZ1dS)\raThis 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|_||_d|_|rR|||\}}|dkrR|t|||dk rb||_ nPt }d|krz||_ n8d} zt t } Wnt jk 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. asciirN.z 127.0.0.1z[%s])_hosttimeoutesmtp_featurescommand_encodingsource_address_auth_challenge_countconnectcloser local_hostnamesocketZgetfqdnZ gethostbynameZ gethostnameZgaierror) rhostportrEr>rArr Zfqdnr.rrrr!s, z SMTP.__init__cCs|Srrrrrr __enter__szSMTP.__enter__cGsNz>z$|d\}}|dkr$t||Wntk r:YnXW5|XdS)NZQUIT)rDdocmdrr)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)rrOrrrset_debuglevel"szSMTP.set_debuglevelcGs@|jdkr,ttjf|dtjint|dtjidS)Nfile)rOprintdatetimeZnowtimesysstderrrrrrr _print_debug+s "zSMTP._print_debugcCs2|jdkr|d||f|jt||f||jS)Nrz connect: to)rOrYrArFcreate_connection)rrGrHr>rrr _get_socket1s   zSMTP._get_socket localhostcCs|r ||_|s||d|dkr||d}|dkr||d|||dd}}z t|}Wntk rztdYnX|s|j}td|||| |||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. :rNrQznonnumeric portzsmtplib.connectconnect:)rAfindrfindint ValueErrorOSError default_portrVauditr[r>sockrRgetreplyrOrYrepr)rrGrHrAirr rrrrC9s&     z SMTP.connectcCs|jdkr|dt||jr|t|tr6||j}t d||z|j |Wqt k rx| t dYqXnt ddS)zSend `s' to the server.rzsend:z smtplib.sendServer not connectedzplease run connect() firstN)rOrYrhrf isinstancestrencoder@rVreZsendallrcrDr)rsrrrsendZs   z SMTP.sendcCs2|dkrd|tf}nd||tf}||dS)zSend a command to the server.r&z%s%sz%s %s%sN)r4ro)rcmdrrlrrrputcmdmsz SMTP.putcmdc CsPg}|jdkr|jd|_z|jtd}Wn:tk rj}z|tdt|W5d}~XYnX|s|td|j dkr| dt |t |tkr|t dd ||d dd |dd }z t|}Wn tk rd }Yq YnX|d d dkrq qd|}|j dkrH| 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. NrbrQz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:izLine too long.s - zreply: retcode (%s); Msg: %a)rRrfZmakefilereadline_MAXLINErcrDrrlrOrYrhlenrappendr+rarbjoin)rresplineerZerrcodeerrmsgrrrrgus>          z SMTP.getreplycCs||||S)z-Send a command, and return its response code.rqrg)rrprrrrrLs 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)rqrErg helo_resp)rnamerr rrrrs z SMTP.heloc CsHi|_||j|p|j|\}}|dkrJt|dkrJ|td||_|dkr`||fSd|_ t |jt st t |j|jdd}|d=|D]}t|}|r|jdd d |dd|jd<qtd |}|r|d }|j|d d } |dkr4|j|d d | |j|<q| |j|<q||fS)zx SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. rurrjrQzlatin-1 authr& z((?P[A-Za-z0-9][A-Za-z0-9\-]*) ?featureN)r?rqehlo_msgrErgrzrDr ehlo_resp does_esmtprkbytesAssertionErrorrhdecodesplit OLDSTYLE_AUTHmatchgetgroupsr2grouplowerstringendr+) rrrr r}eachZ auth_matchmrZparamsrrrr9sD         z SMTP.ehlocCs||jkS)z7Does the server support a given SMTP service extension?)rr?)rZoptrrrhas_extnsz SMTP.has_extncCs|d||dS)z;SMTP 'help' command. Returns help text from server.helprQrrXrrrrs z SMTP.helpcCsd|_|dS)z&SMTP 'rset' command -- resets session.r:rset)r@rLrIrrrrsz SMTP.rsetcCs&z |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)rrrIrrr_rsets z SMTP._rsetcCs |dS)z-SMTP 'noop' command -- doesn't do anything :>noop)rLrIrrrrsz SMTP.nooprcCshd}|rH|jrHtdd|Dr:|dr2d|_ntddd|}|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).0xrrr szSMTP.mail..rzutf-8z SMTPUTF8 not supported by serverrmailz FROM:%s%s) ranyrr@rr|rqr rg)rr#options optionlistrrrrs   z SMTP.mailcCs<d}|r|jrdd|}|ddt||f|S)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r&rrcptzTO:%s%s)rr|rqr rg)rZreciprrrrrrs  z SMTP.rcptcCs|d|\}}|jdkr0|d||f|dkrDt||n|t|tr\t|d}t |}|ddt kr||t }|dt }| ||\}}|jdkr|d||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. r6rzdata:ibr:N.) rqrgrOrYr rkrlr8rmr7bCRLFro)rr rreplqrrrr6%s"         z SMTP.datacCs|dt||S)z5SMTP 'verify' command -- checks for address validity.vrfyrqr/rgrZaddressrrrverifyBsz SMTP.verifycCs|dt||S)z.SMTP 'expn' command -- expands a mailing list.expnrrrrrrIsz 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. Nri+)rrr9rr )rrr}rrrehlo_or_helo_if_neededPs  zSMTP.ehlo_or_helo_if_neededTinitial_response_okc Cs|}|r|nd}|dk rPt|ddd}|d|d|\}}d|_n|d|\}}d|_|d kr|jd7_t|}t||ddd}||\}}|jtkrftd t ||fqf|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 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. Nr:r&)ZeolZAUTHrrQriNz4Server AUTH mechanism infinite loop. Last response: i) upper encode_base64rmrLrBbase64Z decodebytes _MAXCHALLENGErrhr ) rZ mechanismZ authobjectrZinitial_responseZresponserr} challengerrrras2    z SMTP.authcCs0|dkr dS|jdt|jd|dS)zh Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.Nrr:Zmd5)userhmacZHMACpasswordrmZ hexdigestrrrrr 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)rrrrrr auth_plainszSMTP.auth_plaincCs"|dks|jdkr|jS|jSdS)ze Authobject to use with LOGIN authentication. Requires self.user and self.password to be set.N)rBrrrrrr auth_loginszSMTP.auth_loginc s||dstd|jddddg}fdd|D}|sPtd|||_|_|D]t}d | d d }z4|j |t |||d \}} |d kr|| fWSWqbt k r} z| } W5d} ~ XYqbXqb| 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. rz,SMTP AUTH extension not supported by server.zCRAM-MD5ZPLAINZLOGINcsg|]}|kr|qSrr)rrZadvertised_authlistrr szSMTP.login..z(No suitable authentication method found.Zauth_-_rrN) rrrr?rrrrrreplacergetattrr ) rrrrZpreferred_authsZauthlistZ authmethodZ method_namerr}rZlast_exceptionrrrlogins0   z SMTP.logincCs||dstd|d\}}|dkrts>> 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. r:sizezsize=%dri)rrkrlr8rmrrr{rzrrDrrrrr6r ) r from_addrto_addrsr mail_options rcpt_optionsZ esmtp_optsZoptionrr}Zsenderrsrrrrsendmail!sF@            z SMTP.sendmailc Cs||d}|dkr d}nt|dkr2d}ntd|dkr||d|krZ||dn ||d}tj|gd d}|dkrd d ||d ||d ||dfD}dd tj|D}t|} | d =| d=d} zd|f| dWn.t k r(| ds t dd} YnXt R} | r^tjj| |jjddd} |d}n tj| } | j| dd| } W5QRX|||| ||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&rQzResent-z0message has more than one 'Resent-' header blockZSenderFromrcSsg|]}|dk r|qSrr)rfrrrrsz%SMTP.send_message..ToZBccZCccSsg|] }|dqS)rQr)rarrrrsz Resent-BccFr:rzOne or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)utf8)policySMTPUTF8 BODY=8BITMIMEr)linesep)rr)rZget_allrzrbr(r)Z getaddressescopyr|rmUnicodeEncodeErrorrrioBytesIO generatorZBytesGeneratorrZcloneZflattengetvaluer)rr rrrrZresentZ header_prefixZ addr_fieldsZmsg_copyZ internationalZbytesmsggZflatmsgrrr send_messagesX              zSMTP.send_messagecCs<z|j}d|_|r|W5|j}d|_|r6|XdS)z(Close the connection to the SMTP server.N)rfrDrR)rrfrRrrrrDs z SMTP.closecCs.|d}d|_|_i|_d|_||S)zTerminate the SMTP session.quitNF)rLrrr?rrD)rresrrrrs   z SMTP.quit)r\rN)r&)r&)r&)r&)r&)r)r)N)N)N)NNN)rr)NNrr)2rrrrrOrfrRrrrr SMTP_PORTrdrF_GLOBAL_DEFAULT_TIMEOUTr!rJrNrPrYr[rCrorqrgrLrr9rrrrrrrr6rrrrrrrrrrrrrDrrrrrrsh 0   ! 1  3    0  B 8 h M c@s8eZdZdZeZdddddejddfddZddZ 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)Nrrrrrr) rbrrrrrrrrrr!) rrGrHrErrr>rArrrrrr!s(zSMTP_SSL.__init__cCsD|jdkr|d||ft||f||j}|jj||jd}|S)Nrr^r)rOrYrFrZrArrr=)rrGrHr>Z new_socketrrrr[s  zSMTP_SSL._get_socket) rrrr SMTP_SSL_PORTrdrFrr!r[rrrrrs  ric@s0eZdZdZdZdeddfddZd d 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&NcCstj|||||ddS)zInitialize a new instance.)rErAN)rr!)rrGrHrErArrrr!6s z LMTP.__init__r\rcCs|ddkrtj||||dSz(ttjtj|_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/)rANz connect fail:r^) rrCrFZAF_UNIXZ SOCK_STREAMrfrRrcrOrYrDrg)rrGrHrArr rrrrC<s"       z LMTP.connect)r\rN)rrrrr LMTP_PORTr!rCrrrrr&s   r__main__cCs(tj|dtjtjS)Nz: )rVstdoutwriteflushstdinrxr+)promptrrrrVs rrr,zEnter message, end with ^D:r&zMessage length is %dr\rQ)ArrFrr2Z email.utilsr(Z email.messageZemail.generatorrrrrTrVZemail.base64mimerr__all__rrr4rryrcompileIrrcrrrrrrr r r r r r/rr7r8r ImportErrorrrrr{rrrrZfromaddrrZtoaddrsrSr rrxr~rzZserverrPrrrrrrs)       50 /