[SalesForce] Does Messaging.SendEmail() not work in a Platform Event trigger context

I can't figure out why an email isn't being sent. I've got a Platform Event trigger which ultimately is supposed to send an email. Most of the code isn't directly relevant, but here's the surrounding code, called by the trigger handler (cut down for demonstration):

public static void sendEmails() {
    System.debug(Limits.getEmailInvocations());

    Messaging.SingleEmailMessage sem = new Messaging.SingleEmailMessage();
    sem.toAddresses = new List<String>{'myEmailAddress'};
    sem.subject = 'testsubject';
    sem.htmlBody = '<p>test Body</p>';
    Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{sem});

    System.debug(Limits.getEmailInvocations());
}

Debug:

20:22:26.0 (273270760)|USER_DEBUG|[47]|DEBUG|0

20:22:26.0 (346734155)|USER_DEBUG|[55]|DEBUG|1

Yet no email is received (not in Spam either). It's a sandbox, with Deliverability set to "All Email". No exceptions are thrown and I've tried my personal & work email addresses. When executing the Email send code above anonymously, it arrives in my inbox just fine.

EDIT: After further investigation, I've found the following in our server logs:

Our system has detected that this message is 550-5.7.1 not RFC 5322 compliant: 550-5.7.1 'From' header has non compliant domain name. 550-5.7.1 To reduce the amount of spam sent to Gmail, this message has been 550-5.7.1 blocked.

So, now my question is…given that this is an Automated Process user and thus cannot be set to use an Org-Wide Email Address (there's no profile to enable on the address), how can I resolve this?

Best Answer

Limitation

Sadly, there is no apex email support from platform events. Per the documentation:

Sending an email message from a platform event trigger using the Messaging.SingleEmailMessage class is not supported. The email can’t be sent because the sender is the Automated Process entity, which has no email address.

Workaround

You can, however, send emails via email alert where the From Email Address is NOT "Current User's Email Address" but rather some other organization-wide email or default workflow user.

The reason, as outlined in this answer, "emails sent by the Automated Process user was "autoproc@YOURORGID" with no ".com" appended. This meant that Gmail would ignore it and the email wasn't being delivered."

In Apex, you might be able to use the SingleEmailMessage.setOrgWideEmailAddressId method to set the org-wide email and thereby the email be sent from a user other than the automated process user.