SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. Raises SMTPDataError if there is an unexpected reply to the DATA command; the return value from this method is the final response code received wh
(self, msg)
| 554 | return self.getreply() |
| 555 | |
| 556 | def data(self, msg): |
| 557 | """SMTP 'DATA' command -- sends message data to server. |
| 558 | |
| 559 | Automatically quotes lines beginning with a period per rfc821. |
| 560 | Raises SMTPDataError if there is an unexpected reply to the |
| 561 | DATA command; the return value from this method is the final |
| 562 | response code received when the all data is sent. If msg |
| 563 | is a string, lone '\\r' and '\\n' characters are converted to |
| 564 | '\\r\\n' characters. If msg is bytes, it is transmitted as is. |
| 565 | """ |
| 566 | self.putcmd("data") |
| 567 | (code, repl) = self.getreply() |
| 568 | if self.debuglevel > 0: |
| 569 | self._print_debug('data:', (code, repl)) |
| 570 | if code != 354: |
| 571 | raise SMTPDataError(code, repl) |
| 572 | else: |
| 573 | if isinstance(msg, str): |
| 574 | msg = _fix_eols(msg).encode('ascii') |
| 575 | q = _quote_periods(msg) |
| 576 | if q[-2:] != bCRLF: |
| 577 | q = q + bCRLF |
| 578 | q = q + b"." + bCRLF |
| 579 | self.send(q) |
| 580 | (code, msg) = self.getreply() |
| 581 | if self.debuglevel > 0: |
| 582 | self._print_debug('data:', (code, msg)) |
| 583 | return (code, msg) |
| 584 | |
| 585 | def verify(self, address): |
| 586 | """SMTP 'verify' command -- checks for address validity.""" |
no test coverage detected