DNSCheckValidation
in package
implements
EmailValidation
Table of Contents
Interfaces
Constants
- RESERVED_DNS_TOP_LEVEL_NAMES = [ // Reserved Top Level DNS Names 'test', 'example', 'invalid', 'localhost', // mDNS 'local', // Private DNS Namespaces 'intranet', 'internal', 'private', 'corp', 'home', 'lan', ]
- Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G)
- DNS_RECORD_TYPES_TO_CHECK = DNS_MX + DNS_A + DNS_AAAA
Properties
- $dnsGetRecord : DNSGetRecordWrapper
- $error : InvalidEmail|null
- $mxRecords : array<string|int, mixed>
- $warnings : array<string|int, mixed>
Methods
- __construct() : mixed
- getError() : InvalidEmail|null
- Returns the validation error.
- getWarnings() : array<string|int, Warning>
- Returns the validation warnings.
- isValid() : bool
- Returns true if the given email is valid.
- checkDns() : bool
- validateDnsRecords() : bool
- Validate the DNS records for given host.
- validateMxRecord() : bool
- Validate an MX record
Constants
RESERVED_DNS_TOP_LEVEL_NAMES
Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G)
public
mixed
RESERVED_DNS_TOP_LEVEL_NAMES
= [
// Reserved Top Level DNS Names
'test',
'example',
'invalid',
'localhost',
// mDNS
'local',
// Private DNS Namespaces
'intranet',
'internal',
'private',
'corp',
'home',
'lan',
]
DNS_RECORD_TYPES_TO_CHECK
protected
int
DNS_RECORD_TYPES_TO_CHECK
= DNS_MX + DNS_A + DNS_AAAA
Properties
$dnsGetRecord
private
DNSGetRecordWrapper
$dnsGetRecord
$error
private
InvalidEmail|null
$error
$mxRecords
private
array<string|int, mixed>
$mxRecords
= []
$warnings
private
array<string|int, mixed>
$warnings
= []
Methods
__construct()
public
__construct([DNSGetRecordWrapper|null $dnsGetRecord = null ]) : mixed
Parameters
- $dnsGetRecord : DNSGetRecordWrapper|null = null
getError()
Returns the validation error.
public
getError() : InvalidEmail|null
Return values
InvalidEmail|nullgetWarnings()
Returns the validation warnings.
public
getWarnings() : array<string|int, Warning>
Return values
array<string|int, Warning>isValid()
Returns true if the given email is valid.
public
isValid(string $email, EmailLexer $emailLexer) : bool
Parameters
- $email : string
-
The email you want to validate.
- $emailLexer : EmailLexer
-
The email lexer.
Return values
boolcheckDns()
protected
checkDns(string $host) : bool
Parameters
- $host : string
Return values
boolvalidateDnsRecords()
Validate the DNS records for given host.
private
validateDnsRecords(string $host) : bool
Parameters
- $host : string
-
A set of DNS records in the format returned by dns_get_record.
Return values
bool —True on success.
validateMxRecord()
Validate an MX record
private
validateMxRecord(array<string|int, mixed> $dnsRecord) : bool
Parameters
- $dnsRecord : array<string|int, mixed>
-
Given DNS record.
Return values
bool —True if valid.