Re: Pre-RFC discussion about adding a DNS function for Null MX handling
| From: | Christian Schneider | Date: | Wed, 13 May 2026 09:48:28 +0000 |
| Subject: | Re: Pre-RFC discussion about adding a DNS function for Null MX handling | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130861@lists.php.net to get a copy of this message | ||
Am 13.05.2026 um 03:47 schrieb Samuel Fontebasso <samuel.txd@gmail.com>:
> I would like to gather feedback before drafting an RFC for a small addition to PHP's DNS
> functions:
>
> dns_check_mx(string $hostname): bool
>
> The function would check whether a hostname has at least one non-null MX record.
>
> Proposed behavior:
> - false when there are no MX records;
> - false when all MX records are Null MX records;
> - true when at least one MX record has an exchange target other than ".".
Am I correct that this would be equivalent to the following (example.com <http://example.com/> return empty string "" for MX, not
a dot ".")?
array_any(
dns_get_record($hostname, DNS_MX),
fn($r) => $r["target"]
)
I'm torn between providing in-core helper functions for common problems (and getmxrr/dns_get_mx
is indeed misleading/annoying with its bool return value) but on the other hand I'm not sure
checking for an MX is something usually done by the general developer. This sounds more like part of
a library/framework as there are further complications when trying to determine about the ability to
send email to an address.
Because of this I'd probably not add another helper function and try to handle it on the
documentation level instead.
Regards,
- Chris