Forum Moderators: coopster
simply take the part after the "@" of the email address i.e. the domain of the email address and do the following:
if (checkdnsrr($domain, "MX")) {
echo "valid email"
} else {
echo "invalid email"
}
i still need to combine the MX-check with some sort of regex check to see if the format of the email address is valid, but its impossible to submit an address with an invalid host (user can still be wrong)
In the long run, you need to send an email to the address and have the user take action to verify that he/she wanted to join your group.
The point of checkdnsrr() is that it's worthwhile as an aid to the well-intentioned subscriber who accidentally types bill@mcirosfot.com. You can then say - "Sorry try another address".
Tom
thank you for this one -- didn't knew and didn't use this dns-function so far.
However, this seems not to be a genuine "email address" check, as not every domain expecting incoming mail may have an MX record defined, and AFAIK in case of an absent MX record, a sending MTA would simply try to deliver to the A address of a domain instead.
So this means there may be valid mail addresses in domains without MX records, and your check seems just to verify, if a domain zone maintainer has properly defined an MX record or missed that in some sort of sloppyness.
Regards,
R.
i.e.:
if (checkdnsrr($domain, "MX") OR checkdnsrr($domain, "A")) {
echo "valid email";
} else {
echo "invalid email";
}
Note there are domains that have a MX but no A record. (i.e. inactive Homepages that still catch email)
Also note that the whole thing only works on a linux server... but who cares, everybody has linux.