// frameworks and platforms
Via APILaravel email verification with pingutil
Laravel's email and email:dns rules check syntax and DNS, and disposable services pass both because they run real mail servers. A rule object that calls pingutil rejects throwaway and machine-generated addresses, and optionally checks the mailbox, inside the same $request->validate() call you already have.
Where it connects: Laravel custom validation rule object (Illuminate\Contracts\Validation\ValidationRule)
What goes wrong without it
- email:dns passes every temp-mail domain because they all have working MX records.
- Our registration form fills up with accounts nobody can reach, and our transactional mail provider flags the bounces.
- We maintain a disposable-domain array in config and it is always a step behind.
What you can do with Laravel and pingutil
Drop-in rule for registration
Add new DeliverableEmail(checkMailbox: true) to the email rules in your registration FormRequest or Breeze/Fortify controller. Failures show up in $errors like any other rule.
Lighter rule for newsletter and lead forms
Use new DeliverableEmail() without the mailbox check on high-volume forms where only the fast classification is worth the latency.
Shared cache for bursts
Domain categories go into the Cache facade for a day, so repeated attempts from the same disposable domain are rejected without another call.
Set it up
- 1
Create an API key in the pingutil dashboard, add PINGUTIL_KEY to .env and map it in config/services.php as services.pingutil.key.
- 2
Generate the rule with php artisan make:rule DeliverableEmail and replace its body with the example.
- 3
Use a shared cache store (Redis, database or Memcached) so the backoff and categories are shared across workers.
- 4
Add the rule after required and email in your registration validation rules.
- 5
Store the account as usual; treat anything that is not a confirmed valid address as unconfirmed until the user clicks your verification link.
<?php
// app/Rules/DeliverableEmail.php (Laravel 11+, created with: php artisan make:rule DeliverableEmail)
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class DeliverableEmail implements ValidationRule
{
public function __construct(private bool $checkMailbox = false) {}
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$email = strtolower(trim((string) $value));
$domain = substr((string) strrchr($email, '@'), 1);
// Cache the domain's category only; the verdict depends on the full address.
if ($domain !== '' && Cache::get("pingutil:category:{$domain}") === 'disposable') {
$fail('Please use a permanent email address.');
return;
}
$lookup = $this->call('lookup', ['input' => $email, 'skip_enrichment' => true], 2);
if ($lookup !== null) {
Cache::put("pingutil:category:{$lookup['domain']}", $lookup['category'], now()->addDay());
if ($lookup['verdict']['is_spam']) {
$fail("This email address can't be used. Please use a different one.");
return;
}
}
if ($this->checkMailbox) {
$check = $this->call('verify', ['email' => $email], 5);
if (($check['status'] ?? null) === 'invalid') {
$fail($check['did_you_mean']
? "That mailbox does not exist. Did you mean {$check['did_you_mean']}?"
: 'That mailbox does not exist.');
}
}
}
/** Parsed JSON, or null when pingutil is slow, down or rate limited (fail open). */
private function call(string $path, array $body, int $timeout): ?array
{
if (Cache::has('pingutil:backoff')) {
return null;
}
try {
$response = Http::withToken(config('services.pingutil.key'))
->acceptJson()
->connectTimeout(1)
->timeout($timeout)
->post("https://pingutil.com/v1/{$path}", $body);
} catch (ConnectionException) {
return null; // timed out or unreachable
}
if ($response->status() === 429) {
$wait = max(1, (int) $response->json('retry_after_seconds', 60));
Cache::put('pingutil:backoff', true, now()->addSeconds($wait));
return null;
}
if ($response->status() === 401) {
Log::error('pingutil: API key rejected, check PINGUTIL_KEY');
}
return $response->successful() ? $response->json() : null;
}
}
// Usage in a controller or FormRequest:
// $request->validate([
// 'email' => ['required', 'email', new DeliverableEmail(checkMailbox: true)],
// ]);What to do with each result
| pingutil result | Action in Laravel |
|---|---|
| verdict.is_spam: true | Call $fail(); validation fails with the message under the email field. |
| status: invalid | Call $fail() with the did_you_mean suggestion when there is one. |
| status: risky or unknown | Pass; rely on MustVerifyEmail before granting trial perks. |
| category: disposable cached for the domain | Fail immediately without calling the API. |
Limits to plan for
- The rule runs inside the request. The Http client timeouts (1 s connect, 2 s or 5 s total) bound the wait and a ConnectionException passes the address through.
- Catch-all domains are reported as risky, never valid, and some servers refuse to answer, which gives unknown.
- Per-account defaults: 60 requests a minute, 300 verified addresses and 2,000 lookups a day (3,000 and 30,000 a month); a 429 sets a cache backoff. Those are Free plan limits; Enterprise has custom limits.
Laravel documentation
Laravel is a trademark of its owner. This integration uses Laravel's documented extension points; it is not an official Laravel app.
Common questions
- Doesn't email:rfc,dns already catch fake addresses?
- It catches malformed addresses and domains without mail DNS records. Disposable services have valid DNS, and DNS says nothing about whether a specific mailbox exists, so both kinds get through.
- Can I test the rule without calling the API?
- Yes. Http::fake() intercepts the requests, so you can return a disposable or invalid response in a feature test and assert the validation error.
Stop bad addresses in Laravel today
Sign in with your email, create an API key and paste it into the step above. Test on a few real addresses first: the live demo shows exactly what your Laravel setup will receive.