[SalesForce] Community User not receiving welcome email from sandbox

Community users are not receiving their welcome email when testing a custom self registration form in a sandbox org.

Current setup

  1. The custom community user login profile has been configured in the workspace > administration > members section
  2. The Welcome New Member email template is configured
  3. The Send Welcome email checkbox is selected
  4. The email template is Available For Use
  5. The community is Active
  6. System email deliverability is All email

When we use the custom self registration form, it successfully creates the Person Account and User records, but no welcome email is sent.

The custom self registration form uses the below code to create the account and user:

public without sharing class SignupService 

    public Boolean createAccount(SignupParams params) {

        // creates the SObject, but does not insert
        User user = createUser(params); 

        // creates the SObject, but does not insert
        Account person = createAcccount(params); 
        insert person;

        String userId = Site.createExternalUser(user, person.Id, params.password);

        return true;
    }
}

Questions

  1. Why is the email not being sent?
  2. How do I fix it?

Best Answer

  1. You're not setting the parameter to send the email in the method createExternalUser and it seems the default is set to false to not send.
  2. The Site Class docs show that you should be able to send the email by adding a 4th parameter of true:
createExternalUser(user, accountId, password, sendEmailConfirmation)

enter image description here

Related Topic