Detect disposable email addresses in real-time with the TempMailChecker API. Block fake signups, prevent spam, and protect your platform from abuse.
composer require tempmailchecker/php-sdk<?php
require 'vendor/autoload.php';
use TempMailChecker\TempMailChecker;
// Initialize with your API key
$checker = new TempMailChecker('your_api_key_here');
// Check if an email is disposable
if ($checker->isDisposable('user@tempmail.com')) {
echo "Blocked: This is a disposable email";
} else {
echo "Valid: This is a legitimate email";
}$checker = new TempMailChecker('your_api_key');
// Simple boolean check
$isDisposable = $checker->isDisposable('test@10minutemail.com');
// Get full response
$result = $checker->check('user@example.com');
// Returns: ['temp' => false]// Check just the domain
$isDisposable = $checker->isDisposableDomain('tempmail.com');
// Get full response
$result = $checker->checkDomain('guerrillamail.com');Use regional endpoints for lower latency. All endpoints use /check and /usage directly (no /api prefix):
use TempMailChecker\TempMailChecker;
// EU endpoint (default)
$checker = new TempMailChecker('your_api_key');
// or explicitly:
$checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_EU);
// US endpoint
$checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_US);
// Asia endpoint
$checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_ASIA);$usage = $checker->getUsage();
// Returns: ['usage_today' => 15, 'limit' => 25, 'reset' => 'midnight UTC']use TempMailChecker\TempMailChecker;
use Exception;
try {
$isDisposable = $checker->isDisposable('user@example.com');
} catch (Exception $e) {
if (strpos($e->getMessage(), 'Rate limit') !== false) {
// Handle rate limit
} else {
// Handle other errors
echo "Error: " . $e->getMessage();
}
}- Block Fake Signups: Stop disposable emails at registration
- Prevent Promo Abuse: Protect referral programs and coupons
- Clean Email Lists: Remove throwaway addresses from newsletters
- Reduce Spam: Filter out disposable emails in contact forms
- Protect Communities: Ensure real users in forums and chat
- β Simple API: One method call, one boolean response
- β Fast: Sub-millisecond processing, ~70ms real-world latency
- β Massive Database: 277,000+ disposable email domains
- β Auto-Updates: Database updated daily automatically
- β Regional Endpoints: US, EU, and Asia for optimal performance
- β Free Tier: 25 requests/day, no credit card required
- Sign up at tempmailchecker.com
- Get 25 free requests per day
- Start blocking disposable emails immediately
namespace App\Services;
use TempMailChecker\TempMailChecker;
use Exception;
class EmailValidationService
{
private $checker;
public function __construct()
{
$apiKey = config('services.tempmailchecker.key');
if (empty($apiKey)) {
throw new Exception('TempMailChecker API key not configured');
}
$this->checker = new TempMailChecker($apiKey);
}
public function validateEmail(string $email): bool
{
try {
return !$this->checker->isDisposable($email);
} catch (Exception $e) {
\Log::warning('TempMailChecker API error: ' . $e->getMessage());
return true; // Fail open
}
}
}// services.yaml
services:
TempMailChecker\TempMailChecker:
arguments:
$apiKey: '%env(TEMPMAILCHECKER_API_KEY)%'use TempMailChecker\TempMailChecker;
use Exception;
add_filter('registration_errors', function($errors, $sanitized_user_login, $user_email) {
try {
$checker = new TempMailChecker(get_option('tempmailchecker_api_key'));
if ($checker->isDisposable($user_email)) {
$errors->add('disposable_email', 'Disposable email addresses are not allowed.');
}
} catch (Exception $e) {
// Log error but don't block registration
error_log('TempMailChecker error: ' . $e->getMessage());
}
return $errors;
}, 10, 3);- PHP 7.4 or higher
- cURL extension
- JSON extension
- Composer (for installation)
This library is open-source software licensed under the MIT License.
- Documentation: tempmailchecker.com/docs
- Issues: GitHub Issues
- Email: support@tempmailchecker.com
- 277,000+ domains in our database
- Sub-millisecond API processing
- ~70ms latency from global endpoints
- Auto-updates daily
- Free tier with 25 requests/day
- No SDK dependencies - works with any PHP version
Made with β€οΈ by TempMailChecker
