I know this discussion is almost 8 years old, but this morning
I had the problem too, and I found a solution that goes in a
totally different direction. Perhaps still useful. I found your
discussion in:
https://mailing.postfix.users.narkive.com/3vrsw06p/possible-reasons-for-lost-connection-after-data
My situation:
I wanted to send a reply using IPA characters, so way outside
the Latin-1 range, which stupid old Eudora is still restricted
to. I normally run Eudora in Wine under Linux Mint, used to be
Windows. I know there are better programs nowadays, but I want
to keep by decades old mail archive. Converting it isn't trivial.
I tried Evolution for Linux just to send this odd message. But
for some strange reason (unrelated to this discussion) it
wouldn't. After a while I gave up. Then I started playing e-mail
client myself, typing SMTP or ESMTP commands to telnet directly.
And after a while, I had a working solution, using this syntax:
telnet localhost 25 < prepared-file
Localhost is really my remote e-mailserver, because I redirected
ports 25, 587 and 110 to it, using "ssh -L 25:localhost:25 [...]"
etc.
My prepared-file contains simple ESMTP, minimal mail headers, and
the message that I want to send, in UTF-8. It works. Postfix
understandably complains "improper command pipelining after EHLO
from localhost[::1]", because indeed I ignore Postfix's responses
and just rattle on. But it works!
That is, it did until I replaced my test message with a serious
real one. Then I ran into a problem exactly like what you guys
were discussing 8 years ago. Fewer bytes accepted than prepared,
then Postfix logged:
"lost connection after DATA (584 bytes) from localhost[::1]"
although in reality my DATA was over 1600 bytes long.
After a while I found a cause: in a quoted part of the e-mail
I was responding to, there was the word “sector”, like that,
in rounded quotes. Now when I replaced those by simple ASCII
quotes, "sector", the problem was gone!! Message sent
flawlessly!
Even stranger: when I tried this: "sector”, so one straight
quote, then a round one, I got this in the command line:
==
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
telnet> some text after quoted word
?Invalid command
telnet> Connection closed.
==
So I seems it has nothing to do, in my case at least, with
Postfix, TCP packets, hardware, firewalls, whatever, but it's
just telnet interpreting data that in my opinion it should
just pass unaltered. But its behaviour may also be completely
legit and by design. I don't know.
Now of course, in the situation you guys were talking about,
there was probably no telnet at play, but still, the software
that _was_ sending those e-mails, may exhibit a similar
unexpected interpretation of round or straight quotes. Hence
my message. HTH.