Author izomiac
Recipients barry, izomiac, r.david.murray
Date 2020-11-29.05:30:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606627835.9.0.185077481862.issue42498@roundup.psfhosted.org>
In-reply-to
Content
I use a custom e-mail server and noticed I wasn't getting e-mails from FreeNAS.  I tracked the bug down to Python's smtplib.  My home internet can't do outbound port 25, so I use a port forwarding script that I've since learned injects "PROXY TCP4 <client ip> <server ip> <client port> <server port>\r\n".  This isn't a basic SMTP command, so my server responds with "500 Syntax error, command unrecognized\r\n".  

The first glitch in smtplib is that it assumes the server has precognition and upon receiving the syntax error assumes that the *next* command smtplib sends is invalid.  This happens to be "ehlo". After assuming "ehlo" got an error it backs down to "helo".  My server didn't like clients to send two greetings so it responded with "503 Bad sequence of commands", but allowed the connection to proceed anyway after the mild scolding.  smtplib proceeds to issue a "mail FROM" command, then a "rset" command and disconnects in shame after reflecting upon its actions for a while.

So, I modified my server to be a bit more laid back and just accept two greetings.  smtplib proceeds to issue "mail FROM", "rcpt TO", and "data" commands before crashing (raising an "SMTPDataError" in the traceback).

I then modified my server to ignore "PROXY" commands rather than send a syntax error and everything worked perfectly.  I don't code in python, and obviously my SMTP server is a one-off creation, but I figured I ought to let you all know in case you want to make some improvements to smtplib to better follow the SMTP spec and not crash with a cryptic error message three commands later after receiving a non-fatal error message.
History
Date User Action Args
2020-11-29 05:30:35izomiacsetrecipients: + izomiac, barry, r.david.murray
2020-11-29 05:30:35izomiacsetmessageid: <1606627835.9.0.185077481862.issue42498@roundup.psfhosted.org>
2020-11-29 05:30:35izomiaclinkissue42498 messages
2020-11-29 05:30:35izomiaccreate