We have been struggling with this for a day now and the answers on the web have not been helpful, so I'll be explicit in describing our issue.
We have implemented a wrapper method for SendMail()
as follows:
@future
public static void sendEmail(List<String> receiver, String message) {
Messaging.SingleEmailMessage messageOne = new
Messaging.SingleEmailMessage();
messageOne.toAddresses = receivier;
messageOne.optOutPolicy = 'FILTER';
messageOne.subject = 'Flagged Client';
messageOne.setSaveAsActivity(false);
messageOne.plainTextBody = message;
Messaging.SingleEmailMessage[] messageSent = new List<Messaging.SingleEmailMessage> {messageOne};
Messaging.SendEmailResult[] results = Messaging.sendEmail(messageSent);
}
Our Deliverability configuration is as follows:
- Access Level: All mail
- Activate Bounce Management: True
- Enable compliance with standard email security mechanisms: True
- Enable Sender ID compliance: True
- Log activities for email recipients: True
- TLS: Preferred
Our testing results so far:
- When we send via Test Deliverability, messages are delivered and visible on the recipient email system (Gmail, not in SPAM folder).
- When we call this method from Execute Anonymous, messages are delivered and visible on the recipient email system (Gmail, not in SPAM folder).
- When we call from the app, however, messages are NOT delivered on the recipient email system (Gmail, and are not in SPAM folder).
Our Email Log Exports show these results (small sample):
"08/07/2018 20:16:01","97/81-01910-10EF96B5",R,"[email protected]","salesforce+googleprod=redargyle.com__0-76917vvbf0hyr2@gkf9p2u9ufm8ue.29-9az0eam.cs19.bnc.sandbox.salesforce.com","10.220.84.155",1762,0051N000004lu7D,"<-9wc4000000000000000000000000000000000000000000000PD3XMP00Q1VfJU87TpiB3fTgZeZMag@sfdc.net>",,,,,,,"TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384",yes
"08/07/2018 20:16:02","97/81-01910-10EF96B5",D,"[email protected]","salesforce+googleprod=redargyle.com__0-76917vvbf0hyr2@gkf9p2u9ufm8ue.29-9az0eam.cs19.bnc.sandbox.salesforce.com","74.125.197.27",1762,0051N000004lu7D,"<-9wc4000000000000000000000000000000000000000000000PD3XMP00Q1VfJU87TpiB3fTgZeZMag@sfdc.net>",0,"1.051774",,,,,"TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256",unverified
According to the Salesforce docs, the statuses R
& D
indicate success.1
In fact, the log entries look the same, with the same statuses, for the emails we sent via Test Deliverability.