0

I have already searched it through what could be the possible reason for not being able to send a single email as a site guest user on force.com site in salesforce

  • Site guest user's email should be valid
  • Site guest user has all the permission for sending email in public access
  • Site guest user has all the required permission for the vf page along with the apex class

furthermore, I checked all the debug logs for the event and I couldn't find anything unusual

this is my demo code which is perfectly working fine for the admin user

// to.add(quoterec.OwnerId);
to.add('[email protected]');
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setSubject('Quote Accepted by Customer');
email.setToAddresses(to);
email.setHtmlBody('Quote Accepted by Customer');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
System.debug('Test: Check Debug log ==> ' + email);
9
  • Did you set the guest user with a verified email address?
    – Phil W
    Jun 16, 2023 at 5:52
  • yes, I already did that.
    – Jon Snow
    Jun 16, 2023 at 6:11
  • The key is the word "verified". Wondering how you did the verification...?
    – Phil W
    Jun 16, 2023 at 6:19
  • I didn't receive any email for verification, I only changed it with a valid email address
    – Jon Snow
    Jun 16, 2023 at 6:26
  • 2
    I think that's your problem then; you need to use an email address assigned to a user that IS verified, or to the org's verified email address. Sadly the release update doesn't explain how to verify an email address any other way.
    – Phil W
    Jun 16, 2023 at 6:33

1 Answer 1

1

Edit:

You can set organization-Wide Addresses and use them when you want to send the email. Docuement: https://help.salesforce.com/s/articleView?id=sf.email_default_no_reply.htm&type=5 Example: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_outbound_single.htm#apex_Messaging_SingleEmailMessage_setOrgWideEmailAddressId

Please try as suggested, it should work

Previous Answer

I also faced the same problem but the issue is that when we creates the site than it doesn't populate the valid email address. so you should follow the below two steps.

  1. Go to Site Profile →click on View users  → Edit the User  → replace the Email field with the Valid email address and username with name with domain (for ex:[email protected])
  2. Open http://login.salesforce.com or http://test.salesforce.com (depending on your org type) → Forgot Password → Enter guestuser username(username created in step 1) → you will receive an email with a url → click on that (It will say You cannot reset your password but that’s fine our email is verified)

now try to send an email. it will work

3
  • Thanks, @Gopal for the answer I followed the steps that you mentioned here, however, I didn't receive any email when I clicked on the forgot password and I can assure you that the email is valid and I tried with other email address as well but still not receiving email for verification
    – Jon Snow
    Jun 16, 2023 at 12:17
  • @JonSnow may be your org is not developer org. try to use test.salesforce.com to rest the password. Hope your username and email address if fine. (If possible attach a screenshot). I also suggested another approach
    – Gopal
    Jun 16, 2023 at 13:11
  • As per your edited answer I tried creating a new wide org email with Default No-Reply Address and it worked. thanks for your help.
    – Jon Snow
    Jun 19, 2023 at 6:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .