---
schema_version: "1"
id: 3cb9aa22e53bc302797aef3c1565cdc00278d09edd6fbb41f0464037df4d254b
title: Optionally Configure Branded Emails
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/api-community-manager/branded-emails.md
canonical_url: https://docs.mulesoft.com/api-community-manager/branded-emails
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7d85e4f06f31074aa5812ebf6796f26f9ccfb2c066d8d8d044d2e76240c6c292
description: MuleSoft Documentation Site
latest: true
---
---
product: API Community Manager
---

# Optionally Configure Branded Emails

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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](https://help.salesforce.com/s/articleView?id=sales.emailadmin_enable_email_security_compliance.htm&type=5).

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.  Enable **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);
        }

#### Promote Apex Trigger to Production

1.  In the sandbox organization, open **Setup** and use **Quick Find** to go to **Outbound Change
    Sets**.

2.  Click **Continue**.

3.  Click **New**, enter a name and description, and click **Save**.

4.  Click **Add** under **Change Set Components**, set **Component Type** to **Apex Trigger**, and
    add `AnypointEmailNotificationsTrigger`.

5.  Click **Upload**, set the target organization to the production organization, and click
    **Upload**.

6.  In the production organization, open **Setup** and use **Quick Find** to go to **Inbound Change
    Sets**.

7.  Click **Continue**.

8.  If no change sets appear, do these steps:

    1.  Open **Setup** and use **Quick Find** to go to **Deployment Settings**. Click **Edit** next
        to your sandbox organization, enable **Allow Inbound Changes**, and click **Save**.

    2.  Return to **Outbound Change Sets** in the sandbox organization, click **Upload**, set the
        target organization to the production organization, and click **Upload**.

    3.  Wait for the confirmation banner, then return to **Inbound Change Sets** in the production
        organization.

9.  Click **Validate** on the change set, set **Test Option** to **Default Test Option**, and click
    **Validate**.

    > [!NOTE] The change set validation might fail with this coverage error:
    > `AnypointEmailNotificationsTrigger has 0% coverage. Each trigger must have at least 1% code coverage.`
    > This error occurs because the trigger has no test coverage. To resolve it, create a test class
    > as described in the next steps.

10. In the sandbox organization, open the **Developer Console**, click **File** > **New** > **Apex
    Class**, set **Name** to `AnypointEmailNotificationsTriggerTest`, and click **OK**.

11. Enter these code and save:

    @IsTest public class AnypointEmailNotificationsTriggerTest { @IsTest static void testEvent() {
    acm\_pkg\_\_AnypointContracts\_\_ChangeEvent event = new
    acm\_pkg\_\_AnypointContracts\_\_ChangeEvent(); EventBus.ChangeEventHeader header = new
    EventBus.ChangeEventHeader(); header.changeType='CREATE';
    header.entityName='AnypointContracts\_\_x'; header.changeOrigin='here'; header.transactionKey =
    'some'; header.commitUser = 'me'; event.changeEventHeader = header; event.put('ExternalId',
    '476111:1094813'); event.put('acm\_pkg\_\_ApiVersionId\_\_c',
    '66c1049c-ed5c-4f46-9751-33061eb2ce2b:productinformation:v1');
    event.put('acm\_pkg\_\_ApiId\_\_c', '15764979'); event.put('acm\_pkg\_\_InstanceId\_\_c',
    '15764979'); event.put('acm\_pkg\_\_ApplicationId\_\_c', '476111');
    event.put('acm\_pkg\_\_Status\_\_c', 'REVOKED'); event.put('acm\_pkg\_\_TierId\_\_c', '218623');
    event.put('acm\_pkg\_\_ContractType\_\_c', 'Api'); Test.startTest(); Database.SaveResult sr =
    EventBus.publish(event); Test.getEventBus().deliver(); Test.stopTest();
    System.assertEquals(true, sr.isSuccess()); } }

12. Create a new outbound change set and click **Add** under **Change Set Components**. Add both:

    1.  `AnypointEmailNotificationsTrigger` under **Apex Trigger**

    2.  `AnypointEmailNotificationsTriggerTest` under **Apex Class**

13. Upload the change set to the production organization.

14. In the production organization, open **Inbound Change Sets**, click **Validate** on the new
    change set, set **Test Option** to **Run specified tests**, enter
    `AnypointEmailNotificationsTriggerTest`, and click **Validate**.

15. After successful validation, click **Deploy**.

16. To verify the deployment, navigate to **Setup** > **Custom Code** > **Apex Triggers** and
    confirm that `AnypointEmailNotificationsTrigger` appears in the list.

### 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, find 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, find 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, find 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, find 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](https://help.salesforce.com/s/articleView?language=en_US&id=emailadmin_email_relay_overview.htm&type=5).

    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, use the named credential
    configured 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](https://docs.mulesoft.com/access-management/roles).

    This enables the Anypoint user to process API contract events when API contracts are approved or
    revoked.
