- What's new
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Shruti Sridharan is a full stack Salesforce Developer with close to 3 years of experience working on almost every facet of the platform. She often blogs about everything that’s new on the Salesforce platform. Apart from that, Shruti speaks at various conferences, webinars and also leads the Women-in-Tech User Group and Student Group in her hometown. You can reach out to her via her website. Are you tired of hearing about Email Bounces from your marketing users? Struggling with email address validation? Are you losing your potential leads because they didn’t give you the correct email address? If you have faced any of the above-mentioned difficulties, I know how it feels like being a Salesforce administrator.
As a Salesforce administrator, you can implement validation rules and other custom validations to ensure the quality of the email address. But at the end of the day, these options have their own limitations. So how can we resolve this trivial problem in an Admin friendly manner? In other words, with less or no code at all. An Email Address Validation API does all the hard work for you.
I know you have probably started to freak out when you read the word API. No, don’t be. There are a lot of services out there that offers email address validations. One of them that got my attention is the Mailgun email validations tool.
Let’s look at integrating Mailgun’s Email Validation API with Salesforce using External Services. In case if you want to know more about External Services in Salesforce, I would suggest you take a look at this blog series.
Without further ado, let’s start building it!
First, be sure you sign-up for Mailgun if you haven’t already. Once you have an account, navigate over to the Dashboard. Now, click on the API Security tab under Settings and copy the Public Validation Key as shown below –
Now, let’s look at the API that needs to be fired with the Public Validation Key and Email Addressfor validation. The API endpoint that needs to be used for the validation is shown below as an example –
https://api.mailgun.net/v3/address/validate?address=shruti.sridharan22@gmail.com&api_key=<PASTE THE PUBLIC VALIDATION KEY HERE>
Simply supply the address and the api_key as URL parameters and you should be golden!
The response upon invoking the API successfully would look like this:
{
"address": "shruti.sridharan22@gmail.com",
"did_you_mean": null,
"is_disposable_address": false,
"is_role_address": false,
"is_valid": true,
"mailbox_verification": "true",
"parts": {
"display_name": null,
"domain": "gmail.com",
"local_part": "shruti.sridharan22"
},
"reason": null
}
What’s important here is the is_valid
node. A value of true indicates that the Email Address is correct.
Well, that’s with the API. In order to invoke this from Salesforce, we will employ External Service. But for External Service to work, we need to write a Swagger Schema for the same. Let’s take a stab at it.
Here is your Swagger Schema for the above-mentioned API —
{
"swagger": "2.0",
"info": {
"description": "Mailgun Email Address Validation API",
"version": "3.0",
"title": "Mailgun Email Address Validation API"
},
"host": "api.mailgun.net",
"schemes": [
"https"
],
"paths": {
"/v3/address/validate": {
"get": {
"summary": "Validate an Email Address",
"produces": [
"application/json"
],
"parameters": [
{
"in": "query",
"name": "address",
"description": "Email Address to be Verified",
"required": true,
"type": "string"
},
{
"in": "query",
"name": "api_key",
"description": "API Key",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Result of the Email Address Validation",
"schema": {
"$ref": "#/definitions/validationResponse"
}
}
}
}
}
},
"definitions" : {
"validationResponse" : {
"properties": {
"is_valid": {
"description": "is_valid",
"type": "boolean"
}
}
}
}
}
Not so bad, right? If you are NOT able to decipher that (which you really don’t need to), you can take a brief look at the previous External Service blog posts.
However, a new addition here is the introduction of complex schema/object as the output. The return type when the API call was successful (200) looks like this:
"validationResponse" : {
"properties": {
"is_valid": {
"description": "is_valid",
"type": "boolean"
}
}
}
As mentioned earlier, since we are looking only at the is_valid node, we don’t really have to care about the other nodes in the JSON response.
Before we register, make sure we have a Named Credential created with this URL —
https://api.mailgun.net
Now, switch to Lightning Experience and from the Setup, click on External Services. Hit Add an External Service and then copy and paste the Swagger Schema after selecting the checkbox – Provide Complete Schema. In the end, you should be able to see something like this:
Voila! That’s completing about 70% of the whole thing. Registering an API is so simple that it hurts.
Let me break the suspense right away! Your Flow is as simple as this —
Let’s look at each of the elements in the Flow.
The screen will just have a TextBox.
Set the address to the Screen Input Field and the api_key would be the Public Validation Key.
Wait! We need to configure the Outputs also. The response from the API (out of which we are looking ONLY for the is_valid
) will be collected in a Variable of type – Boolean.
All you need to do is to add a Display Text and print the value within the Variable that was created in Step 2 to hold the response from the API.
That’s all! Now let’s see it in action.
We can always expand the Flow by updating a checkbox on the Lead record or so to indicate the validation status. Trust me – API Integration has never become so simple!
Learn about our Deliverability Services
Looking to send a high volume of emails? Our email experts can supercharge your email performance. See how we've helped companies like Lyft, Shopify, Github increase their email delivery rates to an average of 97%.
Last updated on August 27, 2020
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Email's Best of 2021
COVID-19 Survey: How the Pandemic Has Affected Email Sending
Mailgun Validations Features Improved Performance for EU Customers
How To Build An Email List The Right Way
Catch-All Domain Support Is Now Available In Email Validations
Why Email Validation Is Vital For Your Inbox
We Did It: Risk-Free Email Validation From Mailgun
What we've been up to: Mailgun's 2019 Year in Review
Building the Best Email Experience for Creators - Flipsnack’s Story
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Become an Email Pro With Our Templates API
Google Postmaster Tools: Understanding Sender Reputation
Navigating Your Career as a Woman in Tech
Implementing Dmarc – A Step-by-Step Guide
Email Bounces: What To Do About Them
Announcing InboxReady: The deliverability suite you need to hit the inbox
Black History Month in Tech: 7 Visionaries Who Shaped The Future
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Implementing Dmarc – A Step-by-Step Guide
Announcing InboxReady: The deliverability suite you need to hit the inbox
Designing HTML Email Templates For Transactional Emails
Email Security Best Practices: How To Keep Your Email Program Safe
Mailgun’s Active Defense Against Log4j
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Email's Best of 2021
5 Ideas For Better Developer-Designer Collaboration
Mailgun Joins Sinch: The Future of Customer Communications Is Here
Always be in the know and grab free email resources!
By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.