One of the common questions we hear from customers and prospects is “how can I connect SparkPost to Salesforce for notifications?” This quick how-to will walk you through the steps to integrate these two powerful tools.

The first thing you should know is that there is no special magic or custom code required here. Everything you need already exists and is fully documented, this write-up just makes it easy to find all the right information and knot it all together.

Why would you want to do this? SparkPost has some great analytics and reporting tools to give you visibility into your mail streams. This goes way beyond simple SMTP relaying. This is your gateway to being a better sender and boosting engagement from your email campaigns. SparkPost also provides extremely fast and secure transactional mail with deep insight into engagement and activity.  This can be very powerful for tracking both notifications and marketing messages sent out of Salesforce.

Connecting the dots

Following these steps will get you connected at the account level so all your Salesforce-generated emails will flow through your SparkPost account.

Get the SparkPost connection settings

Let’s take a look at your SparkPost account setup first.  If you do not have a SparkPost account already, click here and get one for free.  Log in and select the CONFIGURATION menu, then SMTP SETTINGS.

SparkPost connection settings

This will show you most of the settings you need for your SparkPost configuration.

Settings for SparkPost configuration

On that screen, click on the “Manage API Keys” link and set an API key to allow “Send via SMTP”. Click the Create API Key button and record the generated API key.

IMPORTANT! – copy this API key and save it to a safe location as it will not be available anywhere in the system again.

This API key will be used as the password for your SMTP credentials in your Salesforce configuration.

Now that we have the Host, Port, Username, and Password for your SparkPost account, we move to your Salesforce account and set up the email configuration there.

Sparkpost API

Email Domain Filters

You will also need to set up a valid sending domain if you have not done that already.  If you do have a validated sending domain you can skip this step, otherwise, read on.

Log in and select the CONFIGURATION menu, then SENDING DOMAINS.

Click on the [ADD A DOMAIN] button and complete the fields including a sending subdomain you have already configured in DNS.  There are detailed instructions here on creating sending domains.  Make sure you have access to DNS and complete the steps to validate ownership of the domain before proceeding.

SparkPost API

Configuring Salesforce

Now log in to your Salesforce account with administrator rights and click the gear icon in the top right beside your profile picture, then click SETUP and follow the next steps. Note that if you do not have Salesforce admin rights, these options may not be visible to you.

  1. In the Quick Find field enter “Email Relays“ and select the Email Relays option.Configuring Salesforce
  2. Click Create Email Relay and configure …
    1. Host =
    2. Port = 587
    3. TLS Setting = Required Verify
    4. Enable SMTP Auth = CHECK
    5. Username = SMTP_Injection
    6. Password = Y0urAPIKeyGoesHereWhenYouCreateIt*
    7. Confirm Password =  Y0urAPIKeyGoesHereWhenYouCreateIt*

* Make sure you actually use the API Key you created in SparkPost.

  1. Save the configuration

Next, it is important that you set up an email domain filter in order for the email relay to work properly.

In the Quick Find field enter “Email Domain Filters“ and select the Email Domain Filters option.

  1. Click Create Email Domain Filters and configure …
    1. Sender Domain =  <your SparkPost sender domain>
    2. Recipient Domain =

(leave this as * if you want to send to all domains)

  1. Email Relay = Select the Relay from the previous step
  2. Active = CHECK
    NOTE The wildcard character (*) must precede a second-level domain name. For example, * includes all subdomains of
  3. Save the configuration

Email Domain Filters
You should test at least one email before leaving this how-to and exploring other options.

In the Quick Find field enter “Test Deliverability“ and select the Email Domain Filters option.

  1. Enter your business email address.
  2. Click Send.

Salesforce sends a test message from all IP addresses to your business email address. Each test message specifies the IP address from which it was sent. Note that this could send up to 32 test emails to your address for testing.

Read The Friendly Manual

As I mentioned at the top of this article, this is all documented in other places.  See the actual source documents below.

Wrapping up

We’ve walked through how Salesforce supports external mail relay connectors and shown how to use SparkPost with that to send your mail. It was pretty straightforward and would take you around 15 minutes to do.

If you enjoyed this article, let us know! You can contact us by email and in all the social places @SparkPost.


Subscribe to Newsletter