diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-03-20 20:16:29 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-03-20 20:16:29 (GMT) |
commit | 669b755c92aac40cc3d14e94b9e6dbc1e48d3ef0 (patch) | |
tree | 01c6cfceb003a9399627d491a003f58c4d03f95b /Lib/smtpd.py | |
parent | b4dcb1051441a63ec13aa263484b20d64b935a4b (diff) | |
download | cpython-669b755c92aac40cc3d14e94b9e6dbc1e48d3ef0.zip cpython-669b755c92aac40cc3d14e94b9e6dbc1e48d3ef0.tar.gz cpython-669b755c92aac40cc3d14e94b9e6dbc1e48d3ef0.tar.bz2 |
#14269: smtpd now conforms to the RFC and requires HELO before MAIL.
This is a backward incompatible change, but since it is an RFC conformance bug
and all real mail servers that I know of do conform to the RFC in this regard,
I believe it is an acceptable change for a feature release.
Patch by Jason Killen.
Diffstat (limited to 'Lib/smtpd.py')
-rwxr-xr-x | Lib/smtpd.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py index d66b0d7..748fcae 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -374,6 +374,10 @@ class SMTPChannel(asynchat.async_chat): return address def smtp_MAIL(self, arg): + if not self.seen_greeting: + self.push('503 Error: send HELO first'); + return + print('===> MAIL', arg, file=DEBUGSTREAM) address = self.__getaddr('FROM:', arg) if arg else None if not address: @@ -387,6 +391,10 @@ class SMTPChannel(asynchat.async_chat): self.push('250 Ok') def smtp_RCPT(self, arg): + if not self.seen_greeting: + self.push('503 Error: send HELO first'); + return + print('===> RCPT', arg, file=DEBUGSTREAM) if not self.mailfrom: self.push('503 Error: need MAIL command') @@ -411,6 +419,10 @@ class SMTPChannel(asynchat.async_chat): self.push('250 Ok') def smtp_DATA(self, arg): + if not self.seen_greeting: + self.push('503 Error: send HELO first'); + return + if not self.rcpttos: self.push('503 Error: need RCPT command') return |