- What's new
Catch-All Domain Support Is Now Available In Email Validations
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!
It's easy to get started. And it's free.
See what you can accomplish with the world’s best email delivery platform.
Last updated on August 27, 2020
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
Using Segmentation and Validations for Email List Cleaning
Email List Building From The Ground Up
Email Hard Bounces: The Brick Walls Of Failure
Better Validations For Better Sending
How To Build An Email List The Right Way
Mailpets: For The Love Of Animals
Make Email Accessibility Your New Year’s Resolution
Sunset Policies: Allowing Unengaged Recipients to Ride Off into the Sunset
Email's Best of 2020
Catch-All Domain Support Is Now Available In Email Validations
The Best Time To Send Emails: Cracking The Code
Tips for Building Better Holiday Email Templates
Happy Festivus: Email Deliverability For The Holiday Season
The Basics of Email Subdomains
A Word of Caution For Laravel Developers
Make Email Accessibility Your New Year’s Resolution
Sunset Policies: Allowing Unengaged Recipients to Ride Off into the Sunset
Email's Best of 2020
How To Improve Email Open Rates
Preparing Your Email Infrastructure Correctly
4 Tips To Improve Your Email Deliverability In 2020
COVID-19 Email Communications Dos and Don’ts
How To Use Parallel Programming
Mailgun’s COVID-19 Plan of Action
Password Meters Are Not For Humans
Always be in the know and grab free email resources!
Mailgun is committed to protecting your privacy. Please read ourPrivacy Policybefore providing us with your details.