Send 's' to the server.
(self, s)
| 353 | return (code, msg) |
| 354 | |
| 355 | def send(self, s): |
| 356 | """Send 's' to the server.""" |
| 357 | if self.debuglevel > 0: |
| 358 | self._print_debug('send:', repr(s)) |
| 359 | if self.sock: |
| 360 | if isinstance(s, str): |
| 361 | # send is used by the 'data' command, where command_encoding |
| 362 | # should not be used, but 'data' needs to convert the string to |
| 363 | # binary itself anyway, so that's not a problem. |
| 364 | s = s.encode(self.command_encoding) |
| 365 | sys.audit("smtplib.send", self, s) |
| 366 | try: |
| 367 | self.sock.sendall(s) |
| 368 | except OSError: |
| 369 | self.close() |
| 370 | raise SMTPServerDisconnected('Server not connected') |
| 371 | else: |
| 372 | raise SMTPServerDisconnected('please run connect() first') |
| 373 | |
| 374 | def putcmd(self, cmd, args=""): |
| 375 | """Send a command to the server.""" |
no test coverage detected