in php i came accross the function checkdnsrr. optionally, you can enter one of the following dns record types:
A, MX, NS, SOA, PTR, CNAME, AAAA, or ANY. The default is MX.

i have no idea what any of them mean but wanted to use this function to verify e-mail address domains and links in real-time.

Dani AI

Generated

Good start, — and thanks to for the pointer and for the reading suggestion. The OP already listed the common RRs, so here are compact, practical additions you can use right now to verify whether a domain is set up to receive mail (and what to watch out for).

  1. Basic realtime flow: validate the address syntax; query DNS for MX records and resolve those MX hostnames to A/AAAA; if there are no MX records, SMTP specifies falling back to the domain’s A/AAAA records (treat the domain as an implicit MX). If you want to go further, open an SMTP connection and issue a RCPT TO probe — but note that VRFY/EXPN may be disabled and many domains use catch-all addresses, so the only foolproof test is sending a confirmation email. (rfc-editor.org)

A very small PHP sketch to show the decision flow:

$email = 'user@example.com';
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) exit('bad syntax');
$domain = substr(strrchr($email, '@'), 1);

if (getmxrr($domain, $mxhosts)) {
  // resolve MX hosts -> A/AAAA, then optionally probe SMTP RCPT TO
} else {
  // fallback: check A/AAAA for the domain
  if (!checkdnsrr($domain,'A') && !checkdnsrr($domain,'AAAA')) exit('no mail host');
}

Use getmxrr() to list mail exchangers and then resolve those names to IPs for the SMTP probe. (php.net)

DNS pitfalls to avoid: do not rely on ANY queries — many servers return minimal responses or special HINFO replies to reduce amplification and zoning leakage. CNAME records must not coexist with other data at the same name (so an alias will never carry MX/SOA with it), and you cannot place a CNAME at the zone apex without provider-specific workarounds. PTR (reverse) records live under the in-addr.arpa/ip6.arpa space and are controlled by the IP owner — they’re useful for mailserver reputation checks but aren’t a substitute for MX-based checks. (rfc-editor.org)

There are many RR types beyond the handful in the thread (TXT for SPF/DMARC/DKIM, SRV, TLSA, SVCB, etc.). For a canonical list and references to the spec for each type, consult the IANA DNS parameters registry. Use DNS checks as one layer of validation and always follow up with an actual confirmation email for true mailbox verification. (iana.org)

Recommended Answers

All 3 Replies

might be of some help...I googled for dns record types and many results came up :)

thanks. that somewhat helps.
sorting through the data and after some googling i found the following:

A = address (i think it means you give it a domain name and it will check for an ip address)
MX = mail exchange (i'll use it to verify e-mail addresses)
NS = name server
SOA = start of authority (the first record in every properly configured zone, contains info about the zone)
PTR = pointer (looks to be same as CNAME except instead of you would enter 1.0.168.192.IN-ADDR.ARPA)
CNAME = canonical name (the real name of a host - i think this means if you give it an ip address, it'll check to see if there's a domain name associated with it)
AAAA = IPv6 address (IPv6 increases IP address size from 32 to 128 bits for more levels of hierarchy)
ANY = i take it that means all of the above.

sites i found helpful:

please correct me if i interpreted the info wrong. hope this helps people.

I highly recommend picking up a book or ebook on DNS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.