Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

How To Validate And Verify Email IDs Using MailboxLayer API

smtp based email address validation verification api

Forwarding a set of emails to incorrect or invalid email addresses can be tedious and time-consuming. To avoid this problem, you can utilize an email validation API which helps you thoroughly verify and identify the email sender’s domain and username with minimal fuss. To achieve this, you can add a MailboxLayer to your Delphi and C++ apps using a Windows app development tool.

MailboxLayer can add powerful email address validation to your Delphi and C++ apps

The MailboxLayer is a simple but solid REST API that measures email deliverability & quality. You can easily verify email addresses as they arrive into your system, and you can make sure you only send emails to real customers.

The Low Code way of creating fully functional apps

In this post, we will create our email validation application with FireMonkey App Low Code Wizard. With this wizard, you can create a fully functional Delphi mobile application with multiple screens using just a few easy steps. 

The MailboxLayer API offers an easy to integrate option with RAD Studio

The Mailboxlayer API is simple and secure and comes with easy to integrate URL structure, delivered in lightweight JSON format. Moreover, it offers:

Furthermore, you can power your validation process with a real-time SMTP checker, syntax & typos validation, and/or separate real permanent email addresses from disposable emails.

How do I set up the MailboxLayer API?

Head over to the MailboxLayer API website (https://mailboxlayer.com/) and sign up for the free subscription providing you basic information. After signing up, you can go to a quick start guide dashboard and your API access key will be provided.

How do I request MailboxLayer API endpoints?

Now you have the API access key and all we need to do is to call the base API endpoint (http://apilayer.net/api/check) with the required parameters added to the URL address. The easiest way of doing it is to utilize the REST Client library.

What I liked about this API is that it is immaculately clean! In these images, you can see the sample of calling to API endpoint and with sample JSON response.

After the request to the endpoint, you can get a clear and concise JSON response. Each API response consists of 10 different response objects. You can see them here on the official documentation of the API (https://mailboxlayer.com/documentation)

 How do I connect my applications to the MailboxLayer API?

Well, the crazy and fun part starts here! After following the steps and learning about the API endpoint now you can call the endpoint with RAD Studio Delphi or C++ Builder. 

This REST endpoint calling is done by using 3 REST Client components those are TRESTClient, TRESTResponse, and TRESTRequest.

The rapid way of connecting to APIs – REST Debugger

REST Debugger helps to test and understand how RESTful web service works. You can easily configure, filter, enable OAuth 1.0/2.0 authentication and resource parameters. Moreover, after connecting and receiving the JSON response you can swiftly copy and paste components from the REST Debugger to your Delphi or C++ Builder solution.

How do I build an app which runs on Windows, macOS, Android, and iOS and works with the MailboxLayer API?

As we talked about Low Code Wizard earlier, we will utilize FireMonkey App Low Code Wizard now. Let’s just pause for a moment to speak some more about Low-Code development. 

Low-Code development is a visual approach to software development. With low-code, you can abstract and automate almost every step of the application. You can add database functionalities with a few button clicks. You can add different user interfaces with fully functional controls. Unlike some other “low code” solutions. using the RAD Studio FireMonkey Low Code Wizard does not mean you cannot customize the resulting as much as you want – quite the opposite. The Low Code Wizard can create a fully ready-to-go app when the wizard completes, but you can still add anything you could ever want in terms of additional functionality and customization; you’re not ‘locked in’ to a particular user interface paradigm or set of featuresst because you started out with the low code wizard.

According to the powerful Gartner Group: “By 2024, low-code application development will be responsible for more than 65% of application development activity“.

What can the Low Code App Wizard in RAD Studio do for you?

Within the RAD Studio, you can create a complete application 5x faster than most coding environments. But with this FireMonkey Low-Code Wizard, productivity increases from 5x to 20x or 30x faster.

So, run your RAD Studio and go to Tools -> GetIt Package Manager and search for “low code”! There you can install Low Code App Wizard for FireMonkey. Here you can also learn about it on the GetIt portal (https://getitnow.embarcadero.com/firemonkey-app-low-code-wizard/)

Now you can utilize Low Code App Wizard and generate a fully functional app within seconds. For this, you should go on the menu: File->New->Other and select Multi-Device -> FireMonkey Template App

The Low Code Wizard will now launch. You can specify the project name and specify the folder and select needed any settings you want.

In this case, I only selected the New Empty Form from the additional section. If you check the Sign-Up or the Settings, it will generate other forms with the required source code. 

The REST Debugger adds REST components to our Delphi app the easy way

Now we can paste the saved components which we copied from REST Debugger. And this will add 3 components:

The final steps to parse JSON response

We have finished the process but, I will make some additions to make it more clear for inputting API Access Key and Email value and also parsing ability to our program.

In this case, we just parse these properties: 

The UI for our low code app

As you can see, this is the UI for our app. And I did little binding with LiveBindings to automatically place the response to the Memo1 component.

Here we need some modifications to our RESTRequest1 component. Click the RESTRequest1 and open its Params property and clear out the given parameters that came from REST Debugger.

How to add some code to make the Mailbox API call happen

And place this code to request the endpoint. Moreover, you can apply this event to the Parse Values button to parse exact required values. 

[crayon-67632e3b9eca4431283575/]

As you can see, it this so easy to get to the working application! Since we tried to parse some values only, we did some coding here. 

To put it in a nutshell, we learned how to utilize MailboxLayer API with Delphi. Moreover, we utilized the power of FireMonkey App Low Code Wizard and fetched the data from the endpoint easily using the REST Debugger.

Head over and download the full source code for the MailboxLayer with Delphi demo here: https://github.com/checkdigits/MailboxLayerAPIDemoWithDelphi


RAD Studio can super-charge your apps using the smallest and most efficient amount of code possible. Why not download a trial today and see for yourself?

Exit mobile version