3

I have below apex code under without sharing apex class to send email

Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        semail.setToAddresses(new String[] {'myemail@gmail.com'});
        semail.setSubject('Message from ');
        semail.setPlainTextBody('emailMessage');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail}, true);

The above works fine from the executed anonymous window and I receive the email immediately. But when the same code is executed by a guest site user I don't receive any email.

in logs, I am getting isSuccess() to true from Messaging.SendEmailResult but still don't receive any email

the guest user profile has below permission assigned but still don't get any email.

enter image description here Could someone please help, what am I missing?

tried assigning list email permission but it throw below error

enter image description here

Deliverability settings set to all emails

enter image description here

5
  • why are you assigning the list email permission? Do they have the general send email permission or am I misunderstanding the context in which your code above runs? Jul 6, 2021 at 18:39
  • Could not find send email permission, that's why I tried with the above permission.
    – gs650x
    Jul 6, 2021 at 18:40
  • 1
    your screenshot shows you editing a permission set. Have you taken a look at the actual guest profile where send email would be? You can find this through the following help doc for experiences Jul 6, 2021 at 21:36
  • I am sorry, I am not able to find any permission related to email on profile.
    – gs650x
    Jul 7, 2021 at 3:31
  • I have already assigned send email permission to the profile but still no luck, I have updated my question again.
    – gs650x
    Jul 7, 2021 at 7:13

2 Answers 2

3

Please check your Email Deliverability, if its All Emails

Then go to your community -> WorkSpace->Administrative-> Email and verify the email under Emails section as shown in Screenshot.

enter image description here

0

one of the solution is check the guest user email id , it should be authenticated . Change admin email id for guest user then it will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.