Conditions | 4 |
Paths | 6 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 4.25 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | 2 | public static function existsMx(string $hostname): bool |
|
12 | { |
||
13 | 2 | $hostname = rtrim($hostname, '.') . '.'; |
|
14 | try { |
||
15 | 2 | if (!@dns_check_record($hostname, 'MX')) { |
|
16 | 2 | return false; |
|
17 | } |
||
18 | 2 | $result = @dns_get_record($hostname, DNS_MX); |
|
19 | 2 | return $result !== false && count($result) > 0; |
|
20 | } catch (\Throwable $t) { |
||
21 | // eg. name servers are not found https://github.com/yiisoft/yii2/issues/17602 |
||
22 | } |
||
23 | return false; |
||
24 | } |
||
54 |