Block Trashmail

Detect trashmails and block them

PHP

Check

curl

// Initiate curl instance
$curl = curl_init();

// Set variables
$url = 'https://api.block-trashmail.de';
$email = 'foobar@example.com';

// Set parameters
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_URL => $url . '/check/'. $email,
));

// Make request and save the result to a variable
$result = curl_exec($curl);

// Are there any errors?
if ('null' != $result) {
    // Listed as trashmail?
    if ('true' == $result) {
        echo $email . ' is a trashmail';
    } else {
        echo $email . ' is NOT a trashmail';
    }
} else {
    // Scream and go crazy if there are any errors
    echo 'Something went wrong.';
}

// Clear curl instance to free up some space
curl_close($curl);

file_get_contents()

// Set variables
$url = 'https://api.block-trashmail.de';
$email = 'foobar@example.com';

// Make request and save the result to a variable
$result = file_get_contents($url . '/check/'. $email, false);

// Are there any errors?
if ('null' != $result) {
    // Listed as trashmail?
    if ('true' == $result) {
        echo $email . ' is a trashmail';
    } else {
        echo $email . ' is NOT a trashmail';
    }
} else {
    // Scream and go crazy if there are any errors
    echo 'Something went wrong.';
}