How to validate email addresses in C# .NET

Our free API to validate e-mail addresses is really easy to use in C# .NET

 

Validate e-mail in C# with RestSharp


var client = new RestClient("https://mailcheck.p.rapidapi.com/?domain=EMAIL-OR-DOMAIN");
var request = new RestRequest(Method.GET);
request.AddHeader("x-rapidapi-host", "mailcheck.p.rapidapi.com");
request.AddHeader("x-rapidapi-key", "YOUR-API-KEY");
IRestResponse response = client.Execute(request);
                

 

This will return a JSON-array with information about the domain, and if you should block it or not.

 

Validate e-mail in C# with Unirest


Task<HttpResponse<MyClass>> response = Unirest.get("https://mailcheck.p.rapidapi.com/?domain=EMAIL-OR-DOMAIN")
.header("X-RapidAPI-Host", "mailcheck.p.rapidapi.com")
.header("X-RapidAPI-Key", "YOUR-API-KEY")
.asJson();
                

 

You can of course just send it as a regular GET-request to that URL also, in your favorite way, as long as you have the API-key in the header.

You will receive a JSON response, telling you if this is a disposable e-mail to block, or if there are other issues with the domain:

 


{
    "valid": true,
    "block": true,
    "disposable": true,
    "domain": "mvrht.com",
    "text": "Disposable e-mail",
    "reason": "Heuristics (2a)",
    "mx_host": "mvrht.com",
    "mx_info": "Using MX pointer mvrht.com from DNS with priority: 0",
    "mx_ip": "69.162.74.142"
}
               

 

This will tell you if you should block the domain mvrht.com or not, and the reason to why the API thinks so (disposable e-mail, etc).

To get started for free, and get an API key, click here!