Skip to content

Instantly share code, notes, and snippets.

@laztname
Created August 24, 2021 02:35
Show Gist options
  • Save laztname/03bbd967757475ceb89e15fab3d0292c to your computer and use it in GitHub Desktop.
Save laztname/03bbd967757475ceb89e15fab3d0292c to your computer and use it in GitHub Desktop.
php simple check valid mail and mail server to prevent bounce
<?php
//include 'functions.php';
$email = $_POST['mail'];
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
$domain = array_pop(explode('@', $email));
if(checkdnsrr($domain, 'mx')) {
exit('mail sent');
//mail($email, $subject, $message, $headers);
} else {
exit('mail server not found');
}
} else {
exit('mail doesn\'t valid');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment