- Newest
- Most votes
- Most comments
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:
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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
Relevant content
- Accepted Answerasked 8 months ago
- asked a year ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 10 months ago