Send a command to the server.
(self, cmd, args="")
| 365 | raise SMTPServerDisconnected('please run connect() first') |
| 366 | |
| 367 | def putcmd(self, cmd, args=""): |
| 368 | """Send a command to the server.""" |
| 369 | if args == "": |
| 370 | s = cmd |
| 371 | else: |
| 372 | s = f'{cmd} {args}' |
| 373 | if '\r' in s or '\n' in s: |
| 374 | s = s.replace('\n', '\\n').replace('\r', '\\r') |
| 375 | raise ValueError( |
| 376 | f'command and arguments contain prohibited newline characters: {s}' |
| 377 | ) |
| 378 | self.send(f'{s}{CRLF}') |
| 379 | |
| 380 | def getreply(self): |
| 381 | """Get a reply from the server. |