Search code examples
coldfusionamazon-sescoldfusion-administrator

Limit how many emails/second that ColdFusion sends to AWS SES


I'm currently seeing a bunch of the same errors in our mail.log in ColdFusion 11:

com.sun.mail.smtp.SMTPSendFailedException: 454 Throttling failure: Maximum sending rate exceeded.

There's 200 or so at the exact same datetime, and then another batch of 200 or so at another random time (presumably a different email several hours later).

We're using Amazon SES, and the max send rate on our account is "14 emails/second." Based on those errors we're seeing in mail.log, we assume this rate is being exceeded by ColdFusion trying to send too many at once. Does that assumption sound correct?

Looking around the CF 11 Admin, I'm unsure about what adjustments we need to make to ensure CF doesn't exceed the 14/s rate. Here are some of our current settings (under CF Admin > Server Settings > Mail) which may or may not apply:

[x] Maintain connection to mail server Connection Timeout (in seconds): 60 [ ] Enable SSL socket connections to mail server [x] Enable TLS connection to mail server

Spool Interval (in seconds): 15 Mail Delivery Threads: 10 [x] Spool mail messages for delivery to: Disk Maximum number of messages spooled to memory: 50000


Solution

  • When messages transport is rejected by the SMTP server, the ACF server will respool those items for future delivery, which will retry at regular intervals. As such, you probably don't need to add additional code to handle them, unless you're dealing with emails in the hundreds or thousands.

    If either of the latter are the true, request a rate limit increase from AWS, or look in to another transactional email provider which provides a higher rate ( e.g. - SendGrid ).

    Another option is to connect directly to the SES API and and use its multi-send options to bypass eliminate the throttling of individual SMTP requests. If the emails being sent are error reports, I would suggest using a separate bug tracking application like Rollbar or BugLogHQ, to eliminate redundant transactional bug report mail - thus freeing up the throttle for true application transactional messages.