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