By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Amazon SES, SMTP Error Response: 421 Connection closed by server. Maximum message count per session reached.

1

We have been sending emails from our application over the Amazon SES SMTP servers for some years now. We send about 1000 emails in two or more batches a day. The batch size ranges from 50 to 600 emails and the sending rate is pretty low, 50 emails per second at a maximum.

We did not change anything on our side, neither the application code nor the amount of emails being send. Starting on November 19th we received the following SMTP Error Response from the Amazon SES SMTP Server:

421 Connection closed by server. Maximum message count per session reached.

This error response is received after 350 emails have been sent. This seems to be a new and not yet documented sending limit (per session).

As suggested at https://docs.aws.amazon.com/ses/latest/dg/troubleshoot-smtp.html#troubleshoot-smtp-response-codes, we will update the client side code to be more robust and implement a retry mechanism for the 4xx SMTP response codes.

At least for this special case it seems advisable to also reset the SMTP connection before trying to resend the message in order to start a new SMTP session. Maybe it won't harm to reset the connection for every other 4xx SMTP response code either?

Any suggestions for this problem?

1 Answer
0

The error you're experiencing, "421 Connection closed by server. Maximum message count per session reached," indicates that Amazon SES has implemented a new limit on the number of messages that can be sent in a single SMTP session. This change appears to have been introduced recently, which explains why you're encountering it now despite not making any changes to your application.

To address this issue, you're on the right track with your planned approach. Here are some suggestions:

  1. Implement a retry mechanism: As you mentioned, implementing a retry system for 4xx SMTP response codes is a good practice. This should help handle temporary issues and throttling.

  2. Reset SMTP connections: Your suggestion to reset the SMTP connection before retrying to send a message that received this specific error is excellent. This will start a new session and should allow you to continue sending. It's a good practice to reset the connection after receiving this error, and it may indeed be beneficial to do so for other 4xx errors as well.

  3. Implement connection management: Consider implementing a system that proactively closes and reopens SMTP connections after sending a certain number of messages (e.g., every 300 messages) or after a certain amount of time. This can help prevent hitting the session limit in the first place.

  4. Use exponential backoff: When implementing your retry logic, use an exponential backoff strategy. Start with a short delay (e.g., 5 seconds), then increase it (e.g., 10 seconds, then 30 seconds) for subsequent retries. If multiple retries fail, consider a longer wait (e.g., 20 minutes) before trying again.

  5. Monitor your sending closely: Keep a close eye on your sending metrics and any error responses you receive. This will help you quickly identify and respond to any changes in Amazon SES behavior or limits.

  6. Consider using the Amazon SES API: If SMTP continues to be problematic, you might want to consider switching to the Amazon SES API for sending emails. The AWS SDKs that interact with this API have built-in retry logic and can sometimes be more robust for high-volume sending.

  7. Contact AWS Support: If this new limit is significantly impacting your email sending capabilities, consider reaching out to AWS Support for more information or to discuss your specific use case.

By implementing these suggestions, particularly the connection reset after the 421 error and the proactive connection management, you should be able to work around this new session limit effectively.
Sources
Amazon SES SMTP issues - Amazon Simple Email Service
Amazon SES SMTP issues - Amazon Simple Email Service

profile picture
answered 7 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions