Email Checker Php May 2026
$domain = substr(strrchr($email, "@"), 1); $freeProviders = [ 'gmail.com', 'yahoo.com', 'outlook.com', 'hotmail.com', 'aol.com', 'protonmail.com', 'mail.com', 'gmx.com' ]; return in_array($domain, $freeProviders);
Email addresses can have + , - , . , and even quoted strings. The built-in filter handles edge cases correctly. email checker php
For 95% of applications, syntax + DNS validation is enough. Add disposable detection if you run a contest or free trial. Use SMTP mailbox verification only in offline jobs or if you fully understand the rate limits and anti-abuse policies of receiving mail servers. For 95% of applications, syntax + DNS validation is enough
function isSyntaxValid(string $email): bool function isSyntaxValid(string $email): bool $this->
$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;
var_dump(isDomainValid("user@thisdomaindefinitelydoesnotexist12345.com")); // false This is the gold standard but requires caution. You connect to the mail server and ask if the mailbox exists — without sending an email.
class EmailChecker