Re: Pre-RFC discussion about adding a DNS function for Null MX handling
| From: | Samuel Fontebasso | Date: | Wed, 13 May 2026 23:56:04 +0000 |
| Subject: | Re: Pre-RFC discussion about adding a DNS function for Null MX handling | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130880@lists.php.net to get a copy of this message | ||
On Wed, 13 May 2026 09:50:00 +0000, Christian Schneider
<cschneid@cschneid.com> wrote:
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"]
> )
>
Hi Chris,
Yes, mostly. The raw PHP value for Null MX may be an empty string, as
you noted, but I would still normalize the target so the check is based
on the DNS-level meaning rather than the exact value returned by
dns_get_record():
array_any(
dns_get_record($hostname, DNS_MX),
fn($r) => rtrim($r["target"] ?? "", ".") !==
""
)
I agree this can be done in userland. My point is more about API
semantics: PHP already has DNS-level boolean functions, and RFC 7505
makes "has an MX record" and "has a non-null MX record" two different
DNS-level statements.
I also agree this should not become email deliverability validation. It
should stay strictly limited to MX records.
I am trying to understand whether this DNS-level distinction is worth
exposing explicitly in the existing DNS API.
Regards,
Samuel