function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken Koellner 1Ken Koellner 1 

Anyone know the exact rules from when EMAIL_ADDRESS_BOUNCED exception is raised?

I have some Apex code that using Message.singleEmailMessage instances and Messaging.sendEmail() to send mail.   I enterstand how Contacts can be flagged with a bounced email address.  It appears that in some scenarios, when apex code sends email to a Contact, I get the Exception and in other scenarios, I do not.  I'm trying to understand why.  I even capture debug logs of the emails sent that generated a bounce and tried it in anonymous apex and do not get the exception.  I haven't determined the difference.  Below is an example of a request (with the debug, subject, and body members removed for brevity).  Sending this doesn't yield an Exception from anonymous Apex.  When the send mail was run from an update trigger via apex code in a trigger handler classes, I do get the Exception.  Anyone know what could be different?
 
{
  "bccAddresses" : null,
  "bccSender" : false,
  "ccAddresses" : null,
  "charset" : null,
  "emailPriority" : "Normal",
  "entityAttachments" : null,
  "fileAttachments" : null,
  "inReplyTo" : null,
  "numRecipients" : 2,
  "optOutPolicy" : "SEND",
  "orgWideEmailAddressId" : null,
  "references" : null,
  "replyTo" : null,
  "saveAsActivity" : true,
  "senderDisplayName" : null,
  "sentDate" : null,
  "targetObjectId" : "0031I000002FZaJQAW",
  "templateId" : null,
  "templateName" : null,
  "toAddresses" : [ "spavlova@uog.com" ],
  "treatBodiesAsTemplate" : false,
  "treatTargetObjectAsRecipient" : true,
  "useSignature" : true,
  "userMail" : false,
  "whatId" : "a041I00002v0czMQAQ"
}