Skip to content

Instantly share code, notes, and snippets.

@byeblogs
Last active May 25, 2021 11:40
Show Gist options
  • Save byeblogs/aea50c9f8e038eebc9f9f68bef2d9f10 to your computer and use it in GitHub Desktop.
Save byeblogs/aea50c9f8e038eebc9f9f68bef2d9f10 to your computer and use it in GitHub Desktop.
Check Validasi Email
<?php header("Content-Type: text/plain");
function cekValidEmail($email) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
list($user, $host) = explode('@', $email);
if (!checkdnsrr($host, 'MX')) {
return false;
} else {
return true;
}
} else {
return false;
}
}
$email = array( '[email protected]',
'[email protected]',
'[email protected]'
);
foreach ($email as $mail) {
if(cekValidEmail($mail)) {
echo($mail . " {Email Valid}" . PHP_EOL . PHP_EOL);
} else {
echo($mail . " {Email tidak Valid!}" . PHP_EOL . PHP_EOL);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment