I have set up an Email Service and it's working great but I have encountered a strange issue. I am sending in an email that I know will throw an error in the inbound email handler class. But the error email is being sent directly to the address I'm sending it from, not the one defined in the Email Service settings.

  • The email service is accepting emails from all domains
  • Enable Error Routing is checked, and the Route Error Emails to This Email Address is populated with the correct email.

Here is the gist of my handler class:

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){

  Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();



    result.success = true;

  }catch(DMLException e){

    result.success = false;
    result.message = 'Error Message Here';


  return result;


I thought at first it had something to do with my try/catch block, but when I remove that and just let the handler fail, no error email is sent to either address (neither originating or the routing email address). I'm not super familiar with writing email handler's, so I'm not certain this is the correct way to handle errors so they're sent to the routing address. Any insight is appreciated, thanks!

Side Note: This is occurring in a sandbox environment

  • Did you ever get this resolved? I am having the exact same issue. I've logged a developer support case; we'll see what they say. Commented Feb 5, 2018 at 15:28

1 Answer 1


It seems to be the ill-documented case that Enable Error Routing applies only, or at least primarily, to conditions listed under Failure Response Settings for which the Bounce Message option is selected. Eg, if you create but deactivate an email address for an Email Service, and have Deactivated Email Address Action set to Bounce Message, and Enable Error Routing checked, then the error message will go to the Route Error Emails to This Email Address address. The help text for Enable Error Reporting:

 Prevents the sender being notified when email services cannot process an incoming email.

apparently defines "cannot process an incoming email" to mean "cannot pass the email to your Apex class". Once the email is sent to the Apex class, you're on your own. (Interestingly, setting the Context User for an email address to one with a profile that doesn't have access to the Apex class doesn't cause any errors and the class runs quite happily.)

Returning a Messaging.InboundEmailResult with the success property set to FALSE, or a non-blank message property, will always result in an error message to the original sender. If you want to suppress the error message to the sender and instead send an error to another address, you have to return Messaging.InboundEmailResult.success == TRUE and do the error message handling yourself in your catch block.

You must log in to answer this question.

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