/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc290340644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc423120644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc135730644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc715780644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc174630644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /usr/lib/python3.10/__pycache__/smtplib.cpython-310.pyc (35766B)
o 9jj@sXdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZgdZdZdZdZdZd Zd Zed ejZGd d d eZGdddeZGdddeZGdddeZGdddeZGdddeZ GdddeZ!GdddeZ"GdddeZ#GdddeZ$d d!Z%d"d#Z&d$d%Z'd&d'Z(d(d)Z)zddl*Z*Wn e+yd*Z,Ynwd+Z,Gd,d-d-Z-e,rGd.d/d/e-Z.e/d/d0Z0Gd1d2d2e-Z1e2d3kr*d4d5Z3e3d6Z4e3d75d8Z6e7d9d:Z8 e j9:Z;e;sne8e;Z8qe7dd;e=?e4e6e8e=@dSdS)>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@eZdZdZdS)rz4Base class for all exceptions raised by this module.N__name__ __module__ __qualname____doc__rr/usr/lib/python3.10/smtplib.pyrHrc@r)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. NrrrrrrKrrc@r)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. NrrrrrrRrrc@eZdZdZddZdS)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$rrrrrZs rc@r)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 )r!r"r#r&rrrr$oszSMTPSenderRefused.__init__Nr%rrrrrhs rc@r)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 )r!r'rrrr$}s zSMTPRecipientsRefused.__init__Nr%rrrrrus rc@r)r z'The SMTP server didn't accept the data.Nrrrrrr rr c@r)r z&Error during connection establishment.Nrrrrrr rr c@r)r z"The server refused our HELO reply.Nrrrrrr rr c@r)r zvAuthentication error. Most probably the server didn't accept the username/password combination provided. Nrrrrrr rr cCs>tj|\}}||fdkr|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 startswith addrstring displaynameaddrrrrr s  r cCs$tj|\}}||fdkr|S|S)Nr()r+r,r-r0rrr _addr_onlys r4c 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 rcCstdd|S)Ns(?m)^\.s..)r7r8)bindatarrr_quote_periodsr=cCstdt|S)Nr5r6r:rrr _fix_eolsr>r?FTc@seZdZdZdZdZdZdZdZdZ dZ e Z ddde jdfddZd d Zd d Zd dZddZddZdOddZddZdPddZddZdPddZdPddZdPd d!Zd"d#ZdPd$d%Zd&d'Zd(d)Zd*d+Z dQd-d.Z!dQd/d0Z"d1d2Z#d3d4Z$e$Z%d5d6Z&d7d8Z'd9d:d;d<Z(dRd=d>Z)dRd?d@Z*dRdAdBZ+d9d:dCdDZ,dSdEdFZ- , ,dTdGdHZ.  ,dUdIdJZ/dKdLZ0dMdNZ1dS)VraThis 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. rNehloFr)c Cs||_||_i|_d|_||_d|_|r)|||\}}|dkr)|t|||dur2||_ dSt }d|vr?||_ dSd} z t t } Wn t jyTYnwd| |_ 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_hostnamesocketgetfqdn gethostbyname gethostnamegaierror) r!hostportrLrErHr"r#fqdnr3rrrr$s.   z SMTP.__init__cCs|Srrr!rrr __enter__szSMTP.__enter__cGs`z*z|d\}}|dkrt||Wn tyYnwW|dSW|dS|w)NQUIT)docmdrrrK)r!r r"messagerrr__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)r!r\rrrset_debuglevel"s zSMTP.set_debuglevelcGsD|jdkrttjg|RdtjidSt|dtjidS)Nfile)r\printdatetimenowtimesysstderrr!r rrr _print_debug+s &zSMTP._print_debugcCsF|dur |s td|jdkr|d||f|jt||f||jS)N0Non-blocking socket (timeout=0) is not supportedrz connect: to) ValueErrorr\rgrHrMcreate_connection)r!rRrSrErrr _get_socket1s   zSMTP._get_socket localhostcCs|r||_|s;|d|dkr;|d}|dkr;|d|||dd}}zt|}Wn ty:tdw|s@|j}td|||| |||j |_ d|_ | \}}|jdkrg|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. :rNr^znonnumeric portzsmtplib.connectconnect:)rHfindrfindintriOSError default_portrdauditrkrEsockr_getreplyr\rgrepr)r!rRrSrHir"r#rrrrJ;s(      z SMTP.connectcCs~|jdkr |dt||jr;t|tr||j}t d||z |j |WdSt y:| t dwt d)zSend `s' to the server.rzsend:z smtplib.sendServer not connectedzplease run connect() firstN)r\rgrwru isinstancestrencoderGrdrtsendallrrrKr)r!srrrsend\s    z SMTP.sendcCsd|dkr|}n|d|}d|vsd|vr'|dddd}td|||tdS) zSend a command to the server.r)   z\nz\rz=command and arguments contain prohibited newline characters: N)replacerirr9)r!cmdr r~rrrputcmdosz SMTP.putcmdc Cs:g}|jdur|jd|_ z |jtd}Wnty1}z |tdt|d}~ww|s<|td|j dkrI| dt |t |tkrX|t dd ||d dd |dd }zt|}Wn ty{d }Yn w|d d dkrnqd|}|j dkr| 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. Nrbr^z Connection unexpectedly closed: zConnection unexpectedly closedrzreply:izLine too long.s - zreply: retcode (%s); Msg: %a)r_rumakefilereadline_MAXLINErrrKrr{r\rgrwlenrappendr.rqrijoin)r!resplineer"errcodeerrmsgrrrrv|sH         z SMTP.getreplycCs||||S)z-Send a command, and return its response code.rrv)r!rr rrrrYs 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)rrLrv helo_resp)r!namer"r#rrrrs z SMTP.heloc CsFi|_||j|p |j|\}}|dkr%t|dkr%|td||_|dkr0||fSd|_ t |jt s@Jt |j|j dd}|d=|D]P}t|}|rk|jdd d |dd|jd<qNtd |}|r|d }|j|d d } |dkr|j|d d | |j|<qN| |j|<qN||fS)zx SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. rrryTzlatin-1rauthr)rz((?P[A-Za-z0-9][A-Za-z0-9\-]*) ?featureN)rFrehlo_msgrLrvrrKr ehlo_resp does_esmtprzbytesrwdecodesplit OLDSTYLE_AUTHmatchgetgroupsr7grouplowerstringendr.) r!rr"r#reach auth_matchmrparamsrrrr@sF        z SMTP.ehlocCs||jvS)z7Does the server support a given SMTP service extension?)rrF)r!optrrrhas_extnsz SMTP.has_extncCs|d||dS)z;SMTP 'help' command. Returns help text from server.helpr^rrfrrrrs  z SMTP.helpcCsd|_|dS)z&SMTP 'rset' command -- resets session.rArset)rGrYrUrrrrs z SMTP.rsetcCs$z|WdStyYdSw)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)rrrUrrr_rsets  z SMTP._rsetcCs |dS)z-SMTP 'noop' command -- doesn't do anything :>noop)rYrUrrrr s z SMTP.nooprcCshd}|r$|jr$tdd|Dr|drd|_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) ranyrrGrrrr rv)r!r&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)rrrr rv)r!reciprrrrrr$s  z SMTP.rcptcCs|d|\}}|jdkr|d||f|dkr!t||t|tr-t|d}t |}|ddt kr=|t }|dt }| ||\}}|jdkr[|d||f||fS) 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:ibrAN.) rrvr\rgr rzr{r?r|r=bCRLFr)r!r#r"replqrrrr;,s"        z SMTP.datacC|dt||S)z5SMTP 'verify' command -- checks for address validity.vrfyrr4rvr!addressrrrverifyIz SMTP.verifycCr)z.SMTP 'expn' command -- expands a mailing list.expnrrrrrrPrz SMTP.expncCsn|jdur/|jdur1d|dkrdks3n|\}}d|kr)dks5nt||dSdSdSdS)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+)rrr@rr )r!r"rrrrehlo_or_helo_if_neededWs   zSMTP.ehlo_or_helo_if_neededTinitial_response_okc Cs|}|r |nd}|dur(t|ddd}|d|d|\}}d|_n |d|\}}d|_|d krh|jd7_t|}t||ddd}||\}}|jtkrdtd t ||f|d ks7|d vrp||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. NrAr))eolAUTHrr^riNz4Server AUTH mechanism infinite loop. Last response: i) upper encode_base64r|rYrIbase64 decodebytes _MAXCHALLENGErrwr ) r! mechanism authobjectrinitial_responseresponser"r challengerrrrhs2     z SMTP.authcCs0|durdS|jdt|jd|dS)zh Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.NrrAmd5)userhmacHMACpasswordr| hexdigestr!rrrr 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|dus |jdkr |jS|jS)ze Authobject to use with LOGIN authentication. Requires self.user and self.password to be set.N)rIrrrrrr auth_loginszSMTP.auth_loginc s||ds td|jdgd}fdd|D}|s'td|||_|_|D]:}d| dd }z|j |t |||d \}} |d vrU|| fWSWq0t yj} z| } WYd } ~ q0d } ~ ww| ) 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-MD5PLAINLOGINcsg|]}|vr|qSrr)rradvertised_authlistrr szSMTP.login..z(No suitable authentication method found.auth_-_rrN) rrrrFrrrrrrrgetattrr ) r!rrrpreferred_authsauthlist authmethod method_namer"rrlast_exceptionrrrlogins4   z SMTP.logincCs||ds td|d\}}|dkrqtstd|dur*|dur*td|dur6|dur6td|dus>|durId dl}|d t d |durTt j ||d }|j |j |jd |_ 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 keyfile and certfile parameters, the identity of the SMTP server and client can be checked. This, however, depends on whether the socket module really checks the certificates. This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to the helo greeting. starttlsz+STARTTLS extension not supported by server.STARTTLSrBz&No SSL support included in this PythonN4context and keyfile arguments are mutually exclusive5context and certfile arguments are mutually exclusiverAkeyfile and certfile are deprecated, use a custom context insteadrcertfilekeyfileserver_hostnameF)rrrrY _have_ssl RuntimeErrorriwarningswarnDeprecationWarningssl_create_stdlib_context wrap_socketrurDr_rrrFrr)r!rrcontextrreplyrrrrrs@  z SMTP.starttlsc CsX|g}t|trt|d}|jr-|dr#|dt||D]}||q%| ||\}} |dkrL|dkrB| n| t || |i} t|trV|g}|D]$} | | |\}} |dkrp|dkrp|| f| | <|dkr|| t| qXt| t|kr| t| ||\}} |dkr|dkr| n| t|| | 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. rAsizezsize=%dri)rrzr{r?r|rrrrrrKrrrrr;r ) r! from_addrto_addrsr# mail_options rcpt_options esmtp_optsoptionr"rsenderrsrrrrsendmail(sH@         z SMTP.sendmailcCs||d}|durd}n t|dkrd}ntd|dur>|d|vr-||dn||d}tj|gd d}|durcd d ||d ||d ||dfD}dd tj|D}t|} | d =| d=d} z d|g| dWnt y| dst dd} Ynwt 2} | rtjj| |jjddd} g|ddR}ntj| } | j| dd| } Wdn1swY|||| ||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)r^zResent-z0message has more than one 'Resent-' header blockSenderFromrcSsg|]}|dur|qSrr)rfrrrrsz%SMTP.send_message..ToBccCccSsg|]}|dqS)r^r)rarrrrsz Resent-BccFrArzOne 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_allrrir+r, getaddressescopyrr|UnicodeEncodeErrorrrioBytesIO generatorBytesGeneratorrcloneflattengetvaluer)r!r#rrrrresent header_prefix addr_fieldsmsg_copy internationalbytesmsggflatmsgrrr send_messagesZ             zSMTP.send_messagecCsXz|j}d|_|r |W|j}d|_|r|dSdS|j}d|_|r+|ww)z(Close the connection to the SMTP server.N)r_rKru)r!r_rurrrrKs   z SMTP.closecCs.|d}d|_|_i|_d|_||S)zTerminate the SMTP session.quitNF)rYrrrFrrK)r!resrrrr6s  z SMTP.quitrlrN)r))rr)NNN)rr)NNrr)2rrrrr\rur_rrrr SMTP_PORTrsrM_GLOBAL_DEFAULT_TIMEOUTr$rVr[r]rgrkrJrrrvrYrr@rrrrrrrr;rrrrrrrrrrrr5rKr6rrrrrsh 0   !  1  3    0  B8 h M rcs@eZdZdZeZdddddejddfddZfddZ Z 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. 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|dur |dur td|dur|durtd|dus |dur+ddl} | dtd||_||_|durrr;s  r;ics@eZdZdZdZdeddejffdd Zd fd d Z Z 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.lhlor)Ncstj|||||ddS)zInitialize a new instance.)rLrHrEN)r<r$)r!rRrSrLrHrEr>rrr$<s  z LMTP.__init__rlrcs|ddkrtj|||dS|jdur|jstdz!ttjtj|_|jtjur2|j |jd|_ |j|Wnt yZ|j dkrN| d||jrV|jd|_w|\}}|j dkrl| d|||fS)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.r/)rHNrhz connect fail:rn)r<rJrErirMAF_UNIX SOCK_STREAMrur: settimeoutr_rrr\rgrKrv)r!rRrSrHr"r#r>rrrJBs,         z LMTP.connectr8) rrrrr LMTP_PORTrMr:r$rJrArrr>rrB,s rB__main__cCs(tj|dtjtjS)Nz: )rdstdoutwriteflushstdinrr.)promptrrrrNas rNrr,zEnter message, end with ^D:r)r^zMessage length is %drl)ArrMr&r7 email.utilsr+ email.messageemail.generatorrrr$rardemail.base64mimerr__all__r9r@r9rrrcompileIrrrrrrrrrr r r r r r4rr=r?r ImportErrorrrr;rrHrBrrNfromaddrrtoaddrsr`r#rMrrrserverr]rr6rrrrs)       < / 4