Am 13.05.2026 um 03:47 schrieb Samuel Fontebasso <[email protected]>: > 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
