Skip to content

Commit

Permalink
Hopefully fixed #276 (again) by moving when an email is added to the …
Browse files Browse the repository at this point in the history
…constant SENT_EMAILS

Scratch orgs also can't have deliverability disabled (very frustrating), so I also separately changed email deliverability to 'System Email Only' in the pkg demo org that's used in the pipeline, which should help ensure everything is working going forward 🤞
  • Loading branch information
jongpie committed May 20, 2022
1 parent 7ca80e6 commit 5720941
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ public without sharing class LoggerEmailSender {
}

private static void sendEmail(Messaging.SingleEmailMessage message) {
SENT_EMAILS.add(message);
if (IS_EMAIL_DELIVERABILITY_ENABLED == true) {
List<Messaging.SingleEmailMessage> messages = new List<Messaging.SingleEmailMessage>{ message };
List<Messaging.SendEmailResult> emailResults = Messaging.sendEmail(messages);
SENT_EMAILS.add(message);

if (LoggerParameter.ENABLE_SYSTEM_MESSAGES == false) {
return;
} else if (emailResults.get(0).success == true) {
Logger.info('Logger - The email was sent successfully');
} else {
Logger.info('Logger - The email failed to send: ' + emailResults.get(0).errors.get(0).message);
Logger.warn('Logger - The email failed to send: ' + emailResults.get(0).errors.get(0).message);
}
}
}
Expand Down

0 comments on commit 5720941

Please sign in to comment.