Optionally Configure Branded Emails | MuleSoft Documentation
# Optionally Configure Branded Emails
Anypoint API Community Manager sends notification emails when an API contract is approved or revoked. By default these emails use Anypoint Platform addresses and branding. If you wish to configure them to use your own addresses and branding instead, use these steps.
## Disable Standard Email Security
Branded emails require disabling Salesforce’s standard configuration for Sender Policy Framework (SPF) for email. For more information about this feature, see the Salesforce Help article Enable Email Security Compliance.
To disable the standard configuration, open **Setup** > **Deliverability** > **Email Security Compliance** and ensure the option **Enable compliance with standard email security mechanisms** is not selected.
## Configure Email Addresses
  1. Navigate to **Setup** and use **Quick Find** to go to **Organization-Wide Addresses**.
  2. Set **Display Name** to `EventEmailSender`.
  3. Set **Email Address** to the email address at your organization that sends the API contract event notification emails.
Ensure you can read confirmation emails sent to this address.
  4. Select **Allow All Profiles to Use this From Address**.
  5. Click **Save**.
  6. Open the confirmation email sent to the notification sender email address and click the link to confirm the address.


## Enable Custom Email Notifications
To enable custom email notifications, follow these steps.
### Configure Data Change Capture
  1. Navigate to **Setup** > **Home** > **Integrations** > **External Data Sources** and ensure **Eligible for External Data Change Capture** is enabled.
  2. Set **Polling Interval for External Change Data Capture (seconds)**.
The default is 1800 and the minimum is 300.
  3. Navigate to **Setup**.
  4. Use **Quick Find** to navigate to **Change Data Capture**.
  5. Navigate to **Entities** > **Change Manually** > **Available Entities**.
  6. Move **AnypointContracts** to the **Selected Entities** list, which enables polling on this object.


### Create Apex Trigger
  1. Navigate to **Setup** , use **Quick Find** to go to **Apex Triggers** , and click the **Developer Console** button.
  2. Click **File** > **New** > **Apex Trigger** , set **Name** to `AnypointEmailNotificationsTrigger`, and set **sObject** to `acm_pkg__AnypointContracts__ChangeEvent`.
  3. Enter this code block:
```
  trigger AnypointEmailNotificationsTrigger on acm_pkg__AnypointContracts__ChangeEvent (after insert) {
    List<acm_pkg__AnypointContracts__ChangeEvent> events = Trigger.new;
    acm_pkg__.AnypointEmailNotifications.notifyOnContractUpdates(events);
  }
```

  4. To promote the code from sandbox to production using change sets, follow the steps in Promoting branded emails trigger code from sandbox to production.


### Configure Branded Email Metadata
  1. Navigate to **Setup** and use **Quick Find** to go to **Custom Metadata Types**.
  2. Click **ACM Community Configuration Metadata** > **Manage Records** > **New** to add a record.
  3. Set **Label** to your API community’s name and press tab to automatically complete the **ACM Community Config Metadata Name**.
  4. Open the **Developer Console** and open the **Query Editor**.
  5. Enter `SELECT Id, Name FROM Network` and click **Execute**.
  6. In the list of IDs and communities, choose the row with **Name** equal to your community’s name, double click the ID, and copy it.
  7. In the **ACM Community Config Metadata** field **NetworkId** , paste the ID.
  8. In the **Query Editor** , enter `SELECT Id, Name FROM EmailTemplate` and click **Execute**.
  9. In the list of IDs and email templates, choose the row with **Name** equal to **Contract Approved** , double click the ID, and copy it.
  10. In the **ACM Community Config Metadata** field **ContractApprovedEmailTemplateId** , paste the ID.
  11. In the list of IDs and email templates, choose the row with **Name** equal to **Contract Revoked** , double click the ID, and copy it.
  12. In the **ACM Community Config Metadata** field **ContractRevokedEmailTemplateId** , paste the ID.
  13. In the **Query Editor** , enter `SELECT Id, Address FROM OrgWideEmailAddress` and click **Execute**.
  14. In the list of IDs and email addresses, choose the row with **Address** equal to the organization wide email address you set, double click the ID, and copy it.
  15. In the **ACM Community Config Metadata** field **OrgWideEmailAddressId** , paste the ID.
  16. Click **Save**.
  17. Repeat this process for all additional communities, creating one record for each community.
**NetworkId** is different for each community. **ContractApprovedEmailTemplateId** , **ContractRevokedEmailTemplateId** , and **OrgWideEmailAddressId** may be the same for multiple communities.


### Configure Branded Email Templates
  1. Navigate to **Setup** , use **Quick Find** to go to **Classic Email Templates** , and navigate to **Folder** > **ACM**.
  2. Customize the **Contract Approved** and **Contract Revoked** templates, or create your own templates and configure the **ACM Community Config Metadata** to use them.
  3. Configure an email relay as described in the Salesforce documentation page Send Email Through Email Relay.
If the relay is not configured, notification emails are sent from a Salesforce domain with a sender email address in your organization’s domain. If the actual sender domain and sender email address domain do not match, many email providers mark the notification emails as spam.


## Disable Default Anypoint Email Notifications
The JSON Web Token (JWT) authentication mechanism creates Anypoint user records with member email addresses. To prevent a community member from receiving the default Anypoint notification emails, alter these email addresses so the Anypoint user record email is not a valid address.
  1. In Salesforce, navigate to **Setup** > **Named Credentials**.
  2. Click the **Name** of the named credential `Anypoint` to open it in view mode.
`Anypoint` is the default named credential set in the external data source by the guided setup application. If the named credential has been changed manually, choose the named credential used in the Anypoint external data source.
  3. Click **Edit**.
  4. In the **Per User Subject** formula, add `& ".donotsend" ` after `$User.Email`. Example: `"v2|8745gh23-590d-4h80-b339-1637854e289f|" & $User.Username & "|" & $User.FirstName & "|" & $User.LastName & "|" & $User.Email & ".donotsend" & "|[\"Community User\"]"`


## Anypoint Permissions Configuration
  1. Log in to your API community as an administrative user.
  2. In **Access Management** , click **Users**.
  3. Click the impersonated Anypoint user with the email address of the Salesforce administrator.
  4. Add the Organization Administrator role to the user on each organization and suborganization.
  5. Click **Permissions** , click **API Manager** , and for each environment, open the permissions list and enable the **Manage Contracts** permission.
  6. In the public side of the community, request access to an API with manual approval.
  7. Log in to Anypoint and approve the requested API contract.
This creates the Anypoint user named **Automated Process** , which works with the Salesforce user named **Automated Process** to process triggers.
  8. Grant the Anypoint user named **Automated Process** the **Organization Administrator** role in the main organization using Anypoint Access Management.
This enables the Anypoint user to process API contract events when API contracts are approved or revoked.