SQL - Domain Check
Using the DomainCheck function allows you to check the validity of an email address and puts the results in a new column.
The DOMAINCHECK ON extension uses the Domain Name Services (DNS) protocol to resolve domain names into Internet addresses or find a valid MX record (mail server) for the domain. The domain name is the right portion of an email address such as MyFriend@domainname.com
You must include an email column in your query in order to use this extension.
For example:
SELECT FirstName,LastName,EMAIL
FROM CUSTOMERS
WHERE EMAIL <> ''
DOMAINCHECK ON EMAIL
In the above example, the Domain Checking will be done on column 3 (EMAIL) and the results will be placed in a new column created which would be column 4. If the results are a valid email address, then column 4 will be blank. If the results are not valid, the reason for the error will appear in column 4.
Note: For speed and efficiency, Domain Checking is completed on the first email address in the field. Extra email addresses entered are not verified.
Using DOMAINCHECK ... [ONLYVALID | ONLYINVALID ]
Additional attributes can be added so the final result set only contains valid or non-valid records. For example, you may want a list of only the invalid email addresses, so they could be corrected. Or, you may just want the list to contain valid email addresses because you are going to be exporting the results for a mass email campaign.
The following example will only list records with a valid email address:
SELECT FirstName,LastName,EMAIL
FROM CUSTOMERS
WHERE EMAIL <> ''
DOMAINCHECK ON EMAIL ONLYVALID
The following example will only list records with invalid email address:
SELECT FirstName,LastName,EMAIL
FROM CUSTOMERS
WHERE EMAIL <> ''
DOMAINCHECK ON EMAIL ONLYINVALID