MCPcopy Index your code
hub / github.com/python/cpython / getreply

Method getreply

Lib/smtplib.py:387–434  ·  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 respon

(self)

Source from the content-addressed store, hash-verified

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

Callers 12

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
makefileMethod · 0.45
readlineMethod · 0.45
appendMethod · 0.45
stripMethod · 0.45
joinMethod · 0.45

Tested by 1