SMTP code 221 is sent by the server after the client issues a QUIT command, confirming that the mail transaction is complete and the TCP connection will be closed. This is the normal, graceful end of an SMTP session. If you see 221 without having sent QUIT, the server may be terminating idle connections or enforcing session time limits. The response typically includes the server hostname and a goodbye message.
The client sent QUIT after completing all mail transactions (or deciding not to send). The server acknowledges with 221 and closes the TCP connection. This is the expected end of every SMTP session.
SMTP servers enforce idle timeouts (typically 5-10 minutes). If the client does not send any commands within the timeout window, the server sends 221 and disconnects. This is common when SMTP clients hold persistent connections.
During a graceful server shutdown, the SMTP daemon may send 221 to all connected clients before stopping. This typically happens during scheduled maintenance or service restarts.
Review your mail client or application logs to verify that a QUIT command was sent. If the connection closed unexpectedly, the server may be enforcing idle timeouts.
If you see 221 before completing your mail transaction, your client may be issuing QUIT too early. Trace the full SMTP conversation to identify where the flow deviates.
openssl s_client -connect mail.example.com:587 -starttls smtp
If 221 appears without a QUIT command, the server may be restarting. Check the server's status page or logs for maintenance events.