Email Checker Php May 2026

private function isDisposable(string $domain): bool

function isFreeEmailProvider(string $email): bool email checker php

$domain = substr(strrchr($email, "@"), 1); $recipient = $email; // Get MX servers getmxrr($domain, $mxhosts); if (empty($mxhosts)) $mxhosts = [$domain]; $recipient = $email

$this->errors = []; // Level 1: Syntax if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $this->errors[] = "Invalid email format"; return false; // Level 2: Domain exists $domain = substr(strrchr($email, "@"), 1); if (!checkdnsrr($domain, "MX") && !checkdnsrr($domain, "A")) $this->errors[] = "Domain does not accept email"; return false; // Level 3: Disposable check (optional – depends on your use case) if ($this->isDisposable($domain)) $this->errors[] = "Disposable email addresses not allowed"; return false; // Level 4: SMTP check (optional – use carefully) // if (!$this->smtpCheck($email)) // $this->errors[] = "Mailbox does not exist"; // return false; // return true; // Get MX servers getmxrr($domain