Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local EmailAdress Validator Problems (Windows) #42

Closed
michalbundyra opened this issue Jan 15, 2020 · 3 comments
Closed

Local EmailAdress Validator Problems (Windows) #42

michalbundyra opened this issue Jan 15, 2020 · 3 comments
Assignees

Comments

@michalbundyra
Copy link
Member

Hey there!

If i attach following validator to my validator chain and validate emails like [email protected] or [email protected] or simply my own domain i will get the Validator\EmailAddress::INVALID_SEGMENT message printed.

new Validator\EmailAddress(
    [
        'useDeepMxCheck' => true,
        'useDomainCheck' => true,
        'useMxCheck'     => true
    ]
)

I debugged the code and found out that the call of $result = getmxrr($this->idnToAscii($this->hostname), $mxHosts, $weight); in method validateMXRecords() will return true but the $mxHosts and $weight is empty. Thats why the isValid() return false. I tested it under Windows, linux and Macintosh. Linux and Macintosh works great but Windows fails.

I tried to use $result = dns_get_record($this->idnToAscii($this->hostname), DNS_MX, $mxHosts, $weight); instead but then my php-cgi quits.

Linux/Macintosh:

php -r '$mxHosts = [];$weight  = [];$result = getmxrr("googlemail.com", $mxHosts, $weight);var_dump($result, $mxHosts, $weight);'
bool(true)
array(5) {
  [0]=>
  string(31) "alt1.gmail-smtp-in.l.google.com"
  [1]=>
  string(31) "alt4.gmail-smtp-in.l.google.com"
  [2]=>
  string(31) "alt3.gmail-smtp-in.l.google.com"
  [3]=>
  string(31) "alt2.gmail-smtp-in.l.google.com"
  [4]=>
  string(26) "gmail-smtp-in.l.google.com"
}
array(5) {
  [0]=>
  int(10)
  [1]=>
  int(40)
  [2]=>
  int(30)
  [3]=>
  int(20)
  [4]=>
  int(5)
}

Windows:

php -r '$mxHosts = [];$weight  = [];$result = getmxrr("googlemail.com", $mxHosts, $weight);var_dump($result, $mxHosts, $weight);'
bool(true)
array(0) {
}
array(0) {
}

Originally posted by @FabianKoestring at zendframework/zend-validator#68

@michalbundyra
Copy link
Member Author

Am i the only person who has that strange behavior.


Originally posted by @FabianKoestring at zendframework/zend-validator#68 (comment)

@apteles
Copy link

apteles commented Apr 5, 2020

A litle search in php documention we see that a following note:

screenshot

The question is this, the validation should care about platform that is running and then show some warning that requires the installation of Net_DNS?

One possible solution is:

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    // do something here!
}

@gsteel gsteel self-assigned this Jul 16, 2024
@gsteel
Copy link
Member

gsteel commented Jul 16, 2024

Closing as stale

@gsteel gsteel closed this as completed Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants