An RFC-violating reply from the Dovecot SMTP submission service
uncovered a bug in Mutt. Mutt was not clearing out the input buffer
when closing the connection.
Dovecot was including an extra 250 response after data submission:
DATA
354 OK
Subject: Test 3
Test 3
.
250 2.0.0 223 byte chunk, total 223
250 2.0.0 OK id=1iIqT1-0004wS-Ac
quit
221 2.0.0 Bye
The multiline 250 reply requires a hyphen in the first response. Mutt
closes the connection after the quit, but ends up leaving the
unexpected second line in the input buffer. This causes an error in
the next usage of the connection.
Clean out bufpos and available when closing the socket.