For the complete documentation index, see llms.txt. This page is also available as Markdown.

Salesforce

Salesforce is a cloud-based CRM platform used by businesses to manage customer relationships, sales, and marketing.

With the Mailtrap App for Salesforce, you can route your transactional and marketing emails through Email Sandbox to test and inspect them before they reach real recipients.

In this guide, you'll learn how to:

1) How to configure Named Credentials

The Mailtrap package requires a Named Credential called MailTrap_To_SF to communicate with your Salesforce org. To set it up, you need to:

Useful link: What are Named Credentials?

Assign permission set

First, you need to assign Mailtrap Admin permission set to User who will configure the app.

  • In Setup go to Users (under Administration) and open the Users settings.

  • Under the Permission Set Assignments list, click on Edit Assignments.

  • Select MailTrap Admin and hit the Save button.

Create Named Credentials

Step 1. Connected App to Salesforce

  • Navigate to SetupAppsExternal Client AppsExternal Client App Manager and click on New External Client App.

  • Then, enter the required Basic Information, such as External Client App Name, API Name, Contact Email, and Distribution State.

  • Next, make sure to check the Enable OAuth box and configure it with the following settings:

    • Callback URL – For now, use https://www.example.com (we will change it later);

    • OAuth Scopes – Select Manage user data via APIs (api) and Perform requests at any time (refresh_token, offline_access).

  • Under Flow Enablement, tick the Client Credentials Flow and hit the Create button.

  • Under the Policies tab, click Edit. This will allow you to make the required changes to OAuth Policies.

  • Enable Client Credentials Flow and enter the email address of the Admin User with MailTrap Admin permission set assigned.

  • Select Refresh Token is valid until revoked.

  • Hit the Save button.

  • Go to the Settings tab, expand the OAuth Settings, and click on Consumer Key and Secret.

  • You will be redirected to a page where you can see your Consumer Key and Consumer Secret, you should copy both of them.

Step 2. Create Auth.Provider

Useful links:

  • Navigate to SetupIdentity (Under Settings) → Auth.Providers and click on New.

  • Then, enter the following settings for Auth. Provider:

    • For Provider Type, select Salesforce.

    • For Consumer Key and Consumer Secret you should paste from the Connected App.

    • Paste api refresh_token offline_access in Default Scopes.

    • Authorize Endpoint URL: Your domain URL + /services/oauth2/authorize

    • Token Endpoint URL: Your domain URL + /services/oauth2/token

Domain URL can be found under Company Settings → My Domain.

  • Copy Callback URL from Auth.Providers.

  • Paste the Callback URL into the Connected App instead of https://www.example.com.

Step 3. Named Credentials to Salesforce

Useful links:

  • Navigate to SetupNamed Credentials (under Security)→ click on External Credentials and hit the New button.

  • Then, fill in all necessary information:

    • Name: MailTrap_To_SF

    • Authentication Protocol: OAuth 2.0

    • Authentication Flow Type: Browser Flow

    • Scope: api refresh_token offline_access

    • Identity Provider: select the Auth.Provider you created – ThisOrg

Once you’re done, make sure to hit the Save button.

  • Navigate to Named Credentials, click New.

  • Fill in all necessary information:

    • Label and Name: MailTrap_To_SF

    • URL: Your domain URL

    • External Credential: select External Credential you created before – MailTrap_To_SF

    • Allowed Namespaces for Callouts: RWMailtrap

  • Once you’re done, click Save, and go back to the External Credentials tab to open it.

  • In the Principals section click New.

  • Configure it as in the screenshot below, then click Save.

  • In the Principals section click the menu button underneath Actions:

  • Then, Authenticate:

  • Login to the Salesforce organization, Allow access, and confirm.

Add access to the Named Credentials

  • Go to the Profiles page and open the profile used for your use.

  • At the Enabled External Credential Principal Access section click Edit.

  • Select MailTrap_To_SF – 1 and click Save.

And that’s it, your application is ready!

2) Configure Mailtrap App

To enable the Mailtrap app for Salesforce, you need to connect your Mailtrap account by adding a Mailtrap API Token. To do this:

  • First, navigate to the Mailtrap app via App Launcher.

  • Then, click on Connect Mailtrap account.

If you’re a free user, create your Mailtrap API key (or copy it if you already have one) and paste it in the following bar.

If you’re a paid user or don’t have an account yet, follow the follow the Click here link since the add-on is not added automatically and you need to create a Mailtrap API token.

You will also be redirected to the Mailtrap API Token page, where you’ll see instructions to contact customer support.

Once the support team enables the add-on, the charge will be applied automatically (prorated), and you can start using it.

3) Enabling the Sandbox mode

Before we start: The Mailtrap API token you intend to use for the Salesforce integration with Sandbox should have:

  • At least Viewer permission for the whole account.

  • Admin permission for one or multiple sandboxes.

If your API token doesn’t meet one of these requirements, you won’t be able to activate the add-on.

Step 1. Enable Sandbox mode

To enable the Sandbox mode, navigate to Account Settings again, and then:

  • Paste your API key in the bar, hit Save.

  • Select a sandbox to receive emails

  • Activate the sandbox mode

This will open a new window, where you simply have to click the Turn on button.

Step 2. Sending a test email

To verify the integration, go to the Contacts page and try to send an email to one of your contacts. For example:

If you’ve followed everything correctly so far, once you click on Send, an email should arrive in your Sandbox, just like so:

And that’s it, the integration is complete! 🎉

Last updated

Was this helpful?