damirco/emailcheck

Validates email addresses

Maintainers

Package info

github.com/damirco/emailcheck

pkg:composer/damirco/emailcheck

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-07-04 12:55 UTC

This package is auto-updated.

Last update: 2026-07-04 12:56:29 UTC


README

PHP library for validating email addresses via regex syntax check and DNS MX lookup.

Requirements

  • PHP 8.3+

Installation

composer require damirco/emailcheck

Usage

Single email

use Damirco\Emailcheck\Email;

$email = new Email('user@example.com');

$email->isSyntaxValid(); // true — regex check
$email->isMxValid();     // true — DNS MX lookup
$email->isValid();       // true — both checks pass

(string) $email; // 'user@example.com'

Batch validation

use Damirco\Emailcheck\EmailSet;

$set = new EmailSet([
    'user@example.com',
    'invalid',
    'admin@gmail.com',
]);

// Both syntax + MX
$result = $set->check();
// ['valid' => ['user@example.com', 'admin@gmail.com'], 'invalid' => ['invalid']]

// Syntax only (no DNS)
$result = $set->checkSyntax();

// MX only (no syntax)
$result = $set->checkMxRecords();

// Custom: syntax only, skip MX
$result = $set->check(check_syntax: true, check_mx: false);

EmailSet deduplicates input and filters non-string values automatically.

Testing

composer test              # unit tests (no network)
composer test:integration  # MX/DNS tests (requires network)

License

MIT