1

I am hitting an apex error in production: "SINGLE_EMAIL_LIMIT_EXCEEDED".

I have unit tests in production that run when I do the deployment that call methods as part of the test that send out email messages. These apex classes with the outgoing email code was accidentally deployed to production.

I have removed the code in my sandbox that sends out the emails, but I can't seem to deploy the fixed code as the unit tests in production are calling methods in the classes I'm trying to deploy with the fix if that makes sense.

I can try to wait till the limit resets/lowers, but this is pretty critical and I'd like to get the fix in ASAP as it's production. Is there another way to maybe solve for this?

2 Answers 2

1

You could contact Support and ask for a temporary increase, although by the time they get to it, you'll probably be reset already. I would strongly advise that you modify your code to gracefully fail when the limit is reached instead of throwing an exception. It's possible to make sure that you never get this error with some careful error handling, and remember to use setTargetObjectId with a user Id if you're emailing users to prevent using up your limit faster than you need to.

0

Did you add Test.StartTest() and Test.StopTest() in your test methods?

This provides a separate set of governor limits to the code which is in start and stop block, these two statements cannot be called more than once within a test method and they are not required to be used but in some situations may be critical.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_test.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .