/snap/core18/2979/usr/lib/python3.6/__pycache__
NameSizeModeActions
abc.cpython-36.pyc75150644editdlrm
aifc.cpython-36.pyc259430644editdlrm
antigravity.cpython-36.pyc7790644editdlrm
argparse.cpython-36.pyc604560644editdlrm
ast.cpython-36.pyc117040644editdlrm
asynchat.cpython-36.pyc68150644editdlrm
asyncore.cpython-36.pyc158380644editdlrm
base64.cpython-36.pyc170590644editdlrm
bdb.cpython-36.pyc170330644editdlrm
binhex.cpython-36.pyc120860644editdlrm
bisect.cpython-36.pyc26760644editdlrm
bz2.cpython-36.pyc112820644editdlrm
calendar.cpython-36.pyc258820644editdlrm
cgi.cpython-36.pyc284160644editdlrm
cgitb.cpython-36.pyc100800644editdlrm
chunk.cpython-36.pyc49000644editdlrm
cmd.cpython-36.pyc125750644editdlrm
code.cpython-36.pyc98360644editdlrm
codecs.cpython-36.pyc339000644editdlrm
codeop.cpython-36.pyc62700644editdlrm
colorsys.cpython-36.pyc33110644editdlrm
compileall.cpython-36.pyc82780644editdlrm
configparser.cpython-36.pyc452440644editdlrm
contextlib.cpython-36.pyc111580644editdlrm
copy.cpython-36.pyc70790644editdlrm
copyreg.cpython-36.pyc42440644editdlrm
cProfile.cpython-36.pyc42940644editdlrm
crypt.cpython-36.pyc22420644editdlrm
csv.cpython-36.pyc118550644editdlrm
datetime.cpython-36.pyc545110644editdlrm
decimal.cpython-36.pyc3510644editdlrm
difflib.cpython-36.pyc596420644editdlrm
dis.cpython-36.pyc141810644editdlrm
doctest.cpython-36.pyc755890644editdlrm
dummy_threading.cpython-36.pyc11020644editdlrm
enum.cpython-36.pyc234530644editdlrm
filecmp.cpython-36.pyc83050644editdlrm
fileinput.cpython-36.pyc131520644editdlrm
fnmatch.cpython-36.pyc28740644editdlrm
formatter.cpython-36.pyc175790644editdlrm
fractions.cpython-36.pyc184260644editdlrm
ftplib.cpython-36.pyc283570644editdlrm
functools.cpython-36.pyc240620644editdlrm
genericpath.cpython-36.pyc37260644editdlrm
getopt.cpython-36.pyc62170644editdlrm
getpass.cpython-36.pyc41770644editdlrm
gettext.cpython-36.pyc143060644editdlrm
glob.cpython-36.pyc42590644editdlrm
gzip.cpython-36.pyc162260644editdlrm
hashlib.cpython-36.pyc66920644editdlrm
heapq.cpython-36.pyc142920644editdlrm
hmac.cpython-36.pyc48360644editdlrm
imaplib.cpython-36.pyc421380644editdlrm
imghdr.cpython-36.pyc41500644editdlrm
imp.cpython-36.pyc96960644editdlrm
inspect.cpython-36.pyc797390644editdlrm
io.cpython-36.pyc33870644editdlrm
ipaddress.cpython-36.pyc623860644editdlrm
keyword.cpython-36.pyc17650644editdlrm
linecache.cpython-36.pyc37780644editdlrm
locale.cpython-36.pyc340300644editdlrm
lzma.cpython-36.pyc119920644editdlrm
macpath.cpython-36.pyc56410644editdlrm
macurl2path.cpython-36.pyc18670644editdlrm
mailbox.cpython-36.pyc637520644editdlrm
mailcap.cpython-36.pyc72090644editdlrm
mimetypes.cpython-36.pyc155530644editdlrm
modulefinder.cpython-36.pyc153660644editdlrm
netrc.cpython-36.pyc38360644editdlrm
nntplib.cpython-36.pyc337800644editdlrm
ntpath.cpython-36.pyc131900644editdlrm
nturl2path.cpython-36.pyc14990644editdlrm
numbers.cpython-36.pyc121420644editdlrm
opcode.cpython-36.pyc54130644editdlrm
operator.cpython-36.pyc139130644editdlrm
optparse.cpython-36.pyc480540644editdlrm
os.cpython-36.pyc296280644editdlrm
pathlib.cpython-36.pyc420070644editdlrm
pdb.cpython-36.pyc460940644editdlrm
pickle.cpython-36.pyc426910644editdlrm
pickletools.cpython-36.pyc660200644editdlrm
pipes.cpython-36.pyc78080644editdlrm
pkgutil.cpython-36.pyc162610644editdlrm
platform.cpython-36.pyc291970644editdlrm
plistlib.cpython-36.pyc280550644editdlrm
poplib.cpython-36.pyc133290644editdlrm
posixpath.cpython-36.pyc104560644editdlrm
pprint.cpython-36.pyc158240644editdlrm
profile.cpython-36.pyc139010644editdlrm
pstats.cpython-36.pyc218570644editdlrm
pty.cpython-36.pyc38610644editdlrm
pyclbr.cpython-36.pyc83650644editdlrm
pydoc.cpython-36.pyc837750644editdlrm
py_compile.cpython-36.pyc65440644editdlrm
queue.cpython-36.pyc87550644editdlrm
quopri.cpython-36.pyc57730644editdlrm
random.cpython-36.pyc193300644editdlrm
re.cpython-36.pyc140580644editdlrm
reprlib.cpython-36.pyc54000644editdlrm
rlcompleter.cpython-36.pyc57800644editdlrm
runpy.cpython-36.pyc79820644editdlrm
sched.cpython-36.pyc65640644editdlrm
secrets.cpython-36.pyc21620644editdlrm
selectors.cpython-36.pyc176970644editdlrm
shelve.cpython-36.pyc94580644editdlrm
shlex.cpython-36.pyc69700644editdlrm
shutil.cpython-36.pyc307040644editdlrm
signal.cpython-36.pyc25150644editdlrm
site.cpython-36.pyc165600644editdlrm
sitecustomize.cpython-36.pyc2120644editdlrm
smtpd.cpython-36.pyc266830644editdlrm
smtplib.cpython-36.pyc353400644editdlrm
sndhdr.cpython-36.pyc69130644editdlrm
socket.cpython-36.pyc220130644editdlrm
socketserver.cpython-36.pyc242500644editdlrm
sre_compile.cpython-36.pyc102780644editdlrm
sre_constants.cpython-36.pyc59720644editdlrm
sre_parse.cpython-36.pyc203580644editdlrm
ssl.cpython-36.pyc369390644editdlrm
stat.cpython-36.pyc38510644editdlrm
statistics.cpython-36.pyc181740644editdlrm
string.cpython-36.pyc79640644editdlrm
stringprep.cpython-36.pyc100300644editdlrm
struct.cpython-36.pyc3120644editdlrm
subprocess.cpython-36.pyc354850644editdlrm
sunau.cpython-36.pyc169380644editdlrm
symbol.cpython-36.pyc25170644editdlrm
symtable.cpython-36.pyc104280644editdlrm
sysconfig.cpython-36.pyc159160644editdlrm
tabnanny.cpython-36.pyc69750644editdlrm
tarfile.cpython-36.pyc630850644editdlrm
telnetlib.cpython-36.pyc180970644editdlrm
tempfile.cpython-36.pyc253090644editdlrm
textwrap.cpython-36.pyc136840644editdlrm
this.cpython-36.pyc12650644editdlrm
threading.cpython-36.pyc372340644editdlrm
timeit.cpython-36.pyc116030644editdlrm
token.cpython-36.pyc33200644editdlrm
tokenize.cpython-36.pyc186470644editdlrm
trace.cpython-36.pyc194950644editdlrm
traceback.cpython-36.pyc196460644editdlrm
tracemalloc.cpython-36.pyc172290644editdlrm
tty.cpython-36.pyc10720644editdlrm
turtle.cpython-36.pyc1317510644editdlrm
types.cpython-36.pyc82010644editdlrm
typing.cpython-36.pyc733060644editdlrm
uu.cpython-36.pyc34980644editdlrm
uuid.cpython-36.pyc209180644editdlrm
warnings.cpython-36.pyc132580644editdlrm
wave.cpython-36.pyc178850644editdlrm
weakref.cpython-36.pyc191430644editdlrm
webbrowser.cpython-36.pyc157970644editdlrm
xdrlib.cpython-36.pyc83020644editdlrm
zipapp.cpython-36.pyc55340644editdlrm
zipfile.cpython-36.pyc497280644editdlrm
_bootlocale.cpython-36.pyc9800644editdlrm
_collections_abc.cpython-36.pyc287970644editdlrm
_compat_pickle.cpython-36.pyc65660644editdlrm
_compression.cpython-36.pyc41040644editdlrm
_dummy_thread.cpython-36.pyc48510644editdlrm
_markupbase.cpython-36.pyc79910644editdlrm
_osx_support.cpython-36.pyc96840644editdlrm
_pydecimal.cpython-36.pyc1634020644editdlrm
_pyio.cpython-36.pyc713860644editdlrm
_sitebuiltins.cpython-36.pyc34350644editdlrm
_strptime.cpython-36.pyc159630644editdlrm
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc187790644editdlrm
_threading_local.cpython-36.pyc64250644editdlrm
_weakrefset.cpython-36.pyc78280644editdlrm
__future__.cpython-36.pyc41670644editdlrm
__phello__.foo.cpython-36.pyc1190644editdlrm
Edit: /snap/core18/2979/usr/lib/python3.6/__pycache__/smtplib.cpython-36.pyc (35340B)
3 Nqi @sndZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZdddddd d d d d ddg ZdZdZdZdZdZejdejZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZ Gdd d eZ!Gdd d eZ"Gd d d eZ#d!d Z$d"d#Z%d$dZ&d%d&Z'd'd(Z(y ddl)Z)Wne*k rd)Z+YnXd*Z+Gd+ddZ,e+rGd,d-d-e,Z-ej.d-d.Z/Gd/d0d0e,Z0e1d1krjd2d3Z2e2d4Z3e2d5j4d6Z5e6d7d8Z7x e j8j9Z:e:s$Pe7e:Z7qWe6d9e;e7e,d:Ze3e5e7e>> 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 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.6/smtplib.pyrGsc@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)rrrrrrrrrJsrc@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)rrrrrrrrrQsc@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|_dS)N) smtp_code smtp_errorargs)selfcodemsgrrr__init__bszSMTPResponseException.__init__N)rrrrrrrrrrYsc@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|_dS)N)rrsenderr)rrrrrrrrnszSMTPSenderRefused.__init__N)rrrrrrrrrrgsc@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|_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>tjj|\}}||fdkr6|jjdr.|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 r )emailutils parseaddrstrip startswith) addrstring displaynameaddrrrrr s  cCs$tjj|\}}||fdkr |S|S)Nr )r r )r"r#r$)r'r(r)rrr _addr_onlys r*cCstjddtjdt|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 scCstjdd|S)Ns(?m)^\.s..)r+r,)Zbindatarrr_quote_periodssr/cCstjdt|S)Nz(?:\r\n|\n|\r(?!\n)))r+r,r-)r.rrr _fix_eolssr0FTc@seZdZdZdZdZdZdZdZdZ e Z ddde j dfddZdd Zd d Zd d ZddZddZdMddZddZdNddZddZdOddZdPddZdQdd Zd!d"ZdRd#d$Zd%d&Zd'd(Zd)d*Zffd+d,Z ffd-d.Z!d/d0Z"d1d2Z#e#Z$d3d4Z%d5d6Z&d7d8d9d:Z'dSd;d<Z(dTd=d>Z)dUd?d@Z*d7d8dAdBZ+dVdCdDZ,fffdEdFZ-ddfffdGdHZ.dIdJZ/dKdLZ0dS)WraThis 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|_||_|rL|j||\}}|dkrL|jt|||dk r\||_nPt j }d|krt||_n8d} yt j t j } Wnt j 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_addressconnectcloser local_hostnamesocketZgetfqdnZ gethostbynameZ gethostnameZgaierror) rhostportr<r6r9rrZfqdnr)rrrrs* z SMTP.__init__cCs|S)Nr)rrrr __enter__szSMTP.__enter__cGsNz>y$|jd\}}|dkr$t||Wntk r:YnXWd|jXdS)NZQUIT)docmdrrr;)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_debuglevelcGs@|jdkr,ttjjjf|dtjint|dtjidS)Nfile)rEprintdatetimeZnowZtimesysstderr)rrrrr _print_debug's "zSMTP._print_debugcCs2|jdkr|jd||f|jtj||f||jS)Nrz connect: to)rErMr9r=create_connection)rr>r?r6rrr _get_socket-s  zSMTP._get_socket localhostc Cs|r ||_| r~|jd|jdkr~|jd}|dkr~|d|||dd}}y t|}Wntk r|tdYnX|s|j}|jdkr|jd||f|j |||j |_ d|_ |j \}}|jdkr|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:5s(      z SMTP.connectc Cs|jdkr|jdt|t|drx|jrxt|tr@|j|j}y|jj |Wqt k rt|j t dYqXnt ddS)zSend `s' to the server.rzsend:rXzServer not connectedzplease run connect() firstN) rErMrZhasattrrX isinstancestrencoder8ZsendallrVr;r)rsrrrsendWs   z SMTP.sendcCs2|dkrd|tf}nd||tf}|j|dS)zSend a command to the server.r z%s%sz%s %s%sN)r-ra)rcmdrr^rrrputcmdisz SMTP.putcmdcCsPg}|jdkr|jjd|_xy|jjtd}Wn:tk rn}z|jtdt|WYdd}~XnX|s|jtd|j dkr|j dt |t |tkr|jt dd |j|d djd |dd }y t|}Wntk rd}PYnX|d d d kr Pq Wdj|}|j dkrH|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 - zreply: retcode (%s); Msg: %a)rHrXZmakefilereadline_MAXLINErVr;rr^rErMrZlenrappendr%rTrUjoin)rresplineerZerrcodeerrmsgrrrrYqs>         z SMTP.getreplycCs|j|||jS)z-Send a command, and return its response code.)rcrY)rrbrrrrrBs z 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)rnamerrrrrrss z SMTP.heloc CsLi|_|j|j|p|j|j\}}|d krJt|dkrJ|jtd||_|dkr`||fSd|_ t |jt st t |j|jjdjd}|d=x|D]}tj|}|r|jjddd |jdd|jd<qtjd |}|r|jd j}|j|jd d j} |dkr6|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[A-Za-z0-9][A-Za-z0-9\-]*) ?featureNri)r7rcehlo_msgr<rYrlr;r ehlo_resp does_esmtpr]bytesAssertionErrorrZdecodesplit OLDSTYLE_AUTHmatchgetgroupsr+grouplowerstringendr%) rrurrroeachZ auth_matchmrzZparamsrrrr1s4   &  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)rrrrrrs z SMTP.helpcCsd|_|jdS)z&SMTP 'rset' command -- resets session.r2rset)r8rB)rrrrrsz SMTP.rsetc Cs&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)rB)rrrrrsz SMTP.noopcCshd}|rH|jrHtdd|Dr:|jdr2d|_ntdddj|}|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 szSMTP.mail..rzutf-8z SMTPUTF8 not supported by serverrymailz FROM:%s%s) r}anyrr8rrnrcr rY)rroptions optionlistrrrrs   z SMTP.mailcCs<d}|r|jrddj|}|jddt||f|jS)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r ryrcptzTO:%s%s)r}rnrcr rY)rZreciprrrrrrs  z SMTP.rcptcCs|jd|j\}}|jdkr0|jd||f|dkrDt||n|t|tr\t|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>sz SMTP.verifycCs|jdt||jS)z.SMTP 'expn' command -- expands a mailing list.expn)rcr*rY)rrrrrrEsz SMTP.expncCsf|jdkrb|jdkrbd|jdko.dknsb|j\}}d|koRdknsbt||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+)rtr|r1rsr )rrrorrrehlo_or_helo_if_neededLs   zSMTP.ehlo_or_helo_if_neededT)initial_response_okc Cs|j}|r|nd}|dk rJt|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 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)rr)upper encode_base64r_rBbase64Z decodebytesr ) rZ mechanismZ authobjectrZinitial_responseZresponserro challengerrrrx]s z SMTP.authcCs0|dkr dS|jdtj|jjd|djS)zh Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.Nryr2Zmd5)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_loginszSMTP.auth_loginc s|j|jdstd|jdjdddg}fdd|D}|sPtd|||_|_xv|D]n}d |jj d d }y.|j |t |||d \}} |dkr|| fSWqdt k r} z | } WYdd} ~ XqdXqdW| 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)rrx)advertised_authlistrr szSMTP.login..z(No suitable authentication method found.Zauth_-_)rrN)rr) rrrr7rrrrrreplacerxgetattrr ) rrrrZpreferred_authsZauthlistZ authmethodZ method_namerrorqZlast_exceptionr)rrlogins*      z SMTP.logincCs|j|jdstd|jd\}}|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. r2sizezsize=%drvi)rr]r^r0r_r}rrmrlrr;rrrrr.r) r from_addrto_addrsr mail_options rcpt_optionsZ esmtp_optsZoptionrroZsenderrsrrrrsendmailsF@             z SMTP.sendmailcCs|j|jd}|dkr d}nt|dkr2d}ntd|dkr||d|krZ||dn ||d}tjj|gd d}|dkrd d ||d ||d ||dfD}dd tjj|D}tj|} | d =| d=d} ydj|f|j dWn.t k r(|j ds t dd} YnXt jR} | r^tjj| |jjddd} |d}n tjj| } | 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. z Resent-DateNr rGzResent-z0message has more than one 'Resent-' header blockZSenderFromrcSsg|]}|dk r|qS)Nr)rfrrrrsz%SMTP.send_message..ToZBccZCccSsg|] }|dqS)rGr)rarrrrsz Resent-BccFr2rzOne or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityT)utf8)policySMTPUTF8 BODY=8BITMIMEz )linesep)rr)rZget_allrlrUr"r#Z getaddressescopyrnr_UnicodeEncodeErrorrrioBytesIO generatorZBytesGeneratorrZcloneZflattengetvaluer)rrrrrrZresentZ header_prefixZ addr_fieldsZmsg_copyZ internationalZbytesmsggZflatmsgrrr send_message|sJ           zSMTP.send_messagec Cs<z|j}d|_|r|jWd|j}d|_|r6|jXdS)z(Close the connection to the SMTP server.N)rHr;rX)rrHrXrrrr;s z SMTP.closecCs.|jd}d|_|_i|_d|_|j|S)zTerminate the SMTP session.quitNF)rBr|rtr7r}r;)rZresrrrrs   z SMTP.quit)rPrN)r )r )r )r )r )N)N)N)NNN)1rrrrrErHrtr{r|r} SMTP_PORTrWr=_GLOBAL_DEFAULT_TIMEOUTrr@rDrFrMrOr:rarcrYrBrsr1rrrrrrrr.rrrrrxrrrrrrrr;rrrrrrs^ -   " 1  3    '  B 8 gL 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} | jdtd||_||_|dkrxtj||d}||_t j ||||||dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadr)rr) rUrrrrrrrrrr) rr>r?r<rrr6r9rrrrrrs zSMTP_SSL.__init__cCsD|jdkr|jd||ftj||f||j}|jj||jd}|S)Nrzconnect:)r)rErMr=rNr9rrr5)rr>r?r6Z new_socketrrrrO s   zSMTP_SSL._get_socket) rrrr SMTP_SSL_PORTrWr=rrrOrrrrrs 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.)r<r9N)rr)rr>r?r<r9rrrr)s z LMTP.__init__rPrc Cs|ddkrtj||||dSy(tjtjtj|_d|_|jj|WnBtk r|jdkrl|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_UNIXZ SOCK_STREAMrXrHrVrErMr;rY)rr>r?r9rrrrrr:/s"       z LMTP.connect)rPrN)rrrrr{ LMTP_PORTrr:rrrrrs   r__main__cCs(tjj|dtjjtjjjS)Nz: )rKstdoutwriteflushstdinrjr%)promptrrrrIs rrr,zEnter message, end with ^D:r zMessage length is %drPrG)@rr=rr+Z email.utilsr"Z email.messageZemail.generatorrrrrJrKZemail.base64mimerr__all__rrr-rrkcompileIrrVrrrrrrrr r r r r*r r/r0r ImportErrorrrrrmrrrrZfromaddrrZtoaddrsrIrrrjrprlZserverrFrrrrrr!s         )0 /