MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / getreply

Method getreply

tools/python-3.11.9-amd64/Lib/smtplib.py:380–427  ·  view source on GitHub ↗

Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read response code. - server response string corresponding to response code (multiline

(self)

Source from the content-addressed store, hash-verified

378 self.send(f'{s}{CRLF}')
379
380 def getreply(self):
381 """Get a reply from the server.
382
383 Returns a tuple consisting of:
384
385 - server response code (e.g. '250', or such, if all goes well)
386 Note: returns -1 if it can't read response code.
387
388 - server response string corresponding to response code (multiline
389 responses are converted to a single, multiline string).
390
391 Raises SMTPServerDisconnected if end-of-file is reached.
392 """
393 resp = []
394 if self.file is None:
395 self.file = self.sock.makefile('rb')
396 while 1:
397 try:
398 line = self.file.readline(_MAXLINE + 1)
399 except OSError as e:
400 self.close()
401 raise SMTPServerDisconnected("Connection unexpectedly closed: "
402 + str(e))
403 if not line:
404 self.close()
405 raise SMTPServerDisconnected("Connection unexpectedly closed")
406 if self.debuglevel > 0:
407 self._print_debug('reply:', repr(line))
408 if len(line) > _MAXLINE:
409 self.close()
410 raise SMTPResponseException(500, "Line too long.")
411 resp.append(line[4:].strip(b' \t\r\n'))
412 code = line[:3]
413 # Check that the error code is syntactically correct.
414 # Don't attempt to read a continuation line if it is broken.
415 try:
416 errcode = int(code)
417 except ValueError:
418 errcode = -1
419 break
420 # Check if multiline response.
421 if line[3:4] != b"-":
422 break
423
424 errmsg = b"\n".join(resp)
425 if self.debuglevel > 0:
426 self._print_debug('reply: retcode (%s); Msg: %a' % (errcode, errmsg))
427 return errcode, errmsg
428
429 def docmd(self, cmd, args=""):
430 """Send a command, and return its response code."""

Callers 11

connectMethod · 0.95
docmdMethod · 0.95
heloMethod · 0.95
ehloMethod · 0.95
helpMethod · 0.95
mailMethod · 0.95
rcptMethod · 0.95
dataMethod · 0.95
verifyMethod · 0.95
expnMethod · 0.95
connectMethod · 0.80

Calls 10

closeMethod · 0.95
_print_debugMethod · 0.95
strFunction · 0.85
stripMethod · 0.80
makefileMethod · 0.45
readlineMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected