Skip to content
PHP Logo

How can PHP developers ensure that an email address is "authentic" rather than just "externally valid"?

To ensure that an email address is "authentic" rather than just "externally valid," PHP developers can use the `checkdnsrr` function to verify that the domain part of the email address has valid DNS records. This helps to confirm that the email address is associated with a real domain and can receive emails.

php
function isAuthenticEmail($email) {
    list($user, $domain) = explode('@', $email);
    return checkdnsrr($domain, 'MX');
}

$email = 'example@example.com';
if (isAuthenticEmail($email)) {
    echo 'Email address is authentic.';
} else {
    echo 'Email address is not authentic.';
}