How to validate email addresses in C

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

 

Validate e-mail in C with libcurl


CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://mailcheck.p.rapidapi.com/?domain=EMAIL-OR-DOMAIN");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "x-rapidapi-host: mailcheck.p.rapidapi.com");
headers = curl_slist_append(headers, "x-rapidapi-key: YOUR-API-KEY");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

CURLcode ret = curl_easy_perform(hnd);
                

 

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

 

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": "butter9x.com",
    "text": "Disposable e-mail",
    "reason": "Heuristics (x2a)",
    "mx_host": "mx37.m1bp.com",
    "mx_info": "Using MX pointer butter9x.com from DNS with priority: 0",
    "mx_ip": "192.110.255.237"
}
               

 

This will tell you if you should block the domain butter9x.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!