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