mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-01 21:19:25 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c3a79217c | |||
| 749b423775 |
@@ -84,7 +84,7 @@ class EmailValidator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dns = true;
|
$dns = false;
|
||||||
if ($checkDNS) {
|
if ($checkDNS) {
|
||||||
$dns = $this->checkDNS();
|
$dns = $this->checkDNS();
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,12 @@ class EmailValidator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($strict) ? (!$this->hasWarnings() && $dns) : true;
|
return ($strict) ? $this->checkStrict($dns) : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkStrict($dns)
|
||||||
|
{
|
||||||
|
return !($this->hasWarnings() && !$dns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,16 +149,9 @@ class EmailValidator
|
|||||||
|
|
||||||
protected function checkDNS()
|
protected function checkDNS()
|
||||||
{
|
{
|
||||||
$checked = false;
|
$checked = true;
|
||||||
if (!function_exists('dns_get_record') && (
|
|
||||||
in_array(self::DNSWARN_NO_RECORD, $this->warnings) &&
|
|
||||||
in_array(self::DNSWARN_NO_MX_RECORD, $this->warnings)
|
|
||||||
)) {
|
|
||||||
return $checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = checkdnsrr(trim($this->parser->getParsedDomainPart()), 'MX');
|
$result = checkdnsrr(trim($this->parser->getParsedDomainPart()), 'MX');
|
||||||
$checked = true;
|
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->warnings[] = self::DNSWARN_NO_RECORD;
|
$this->warnings[] = self::DNSWARN_NO_RECORD;
|
||||||
|
|||||||
@@ -303,4 +303,14 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInvalidEmailsWithDNSAndStrict()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->validator->isValid('test@test', true, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvalidEmailsWithStrict()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->validator->isValid('"test"@test', false, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user