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 theRoute 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();
try{
//SOME LOGIC HERE
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