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.
This will show you most of the settings you need for your 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.
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.
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.
- In the Quick Find field enter “Email Relays“ and select the Email Relays option.
- Click Create Email Relay and configure …
- Host = smtp.sparkpostmail.com
- Port = 587
- TLS Setting = Required Verify
- Enable SMTP Auth = CHECK
- Username = SMTP_Injection
- Password = Y0urAPIKeyGoesHereWhenYouCreateIt*
- Confirm Password = Y0urAPIKeyGoesHereWhenYouCreateIt*
* Make sure you actually use the API Key you created in SparkPost.
- 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.
- Click Create Email Domain Filters and configure …
- Sender Domain = <your SparkPost sender domain>
- Recipient Domain = *
(leave this as * if you want to send to all domains)
- Email Relay = Select the Relay from the previous step
- Active = CHECK
NOTE The wildcard character (*) must precede a second-level domain name. For example, *.example.com includes all subdomains of example.com.
- Save the configuration
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.
- Enter your business email address.
- 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.
- Setting up a Salesforce Email Relay
- Configuring the Salesforce Email Domain FIlter
- Getting the SparkPost SMTP settings
- Creating a Sending Domain in SparkPost
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.