is_open_email( $p_email );
}
/**
* Determines if the email address is an email address in an open domain. These are
* addresses that users can sign up for, typically free. They then has to login to
* these address to get the emails. These are not considered to be
* disposable emails, however, if the application is providing a free
* trial for an expensive server, then users can signup for more accounts
* to get further trials.
*
* If applications are to block these addresses, it is important to be aware
* that some users use open webmail as their primary email and that such
* service providers include hotmail, gmail, and yahoo.
*
* @param $p_email The email address to check.
* @returns true: open domain email, false: otherwise.
*/
function is_open_email( $p_email ) {
$t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email );
return in_array( $t_domain, DisposableEmailChecker::$open_domains_array );
}
/**
* A debugging function that takes in an email address and dumps out the
* details for such email.
*
* @param $p_email The email address to echo results for. This must be a
* safe script (i.e. no javascript, etc).
*/
function echo_results( $p_email ) {
echo 'email address = ', htmlspecialchars( $p_email ), '
';
echo 'is_disposable_email = ', DisposableEmailChecker::is_disposable_email( $p_email ), '
';
echo 'is_forwarding_email = ', DisposableEmailChecker::is_forwarding_email( $p_email ), '
';
echo 'is_trash_email = ', DisposableEmailChecker::is_trash_email( $p_email ), '
';
echo 'is_time_bound_email = ', DisposableEmailChecker::is_time_bound_email( $p_email ), '
';
echo 'is_shredder_email = ', DisposableEmailChecker::is_shredder_email( $p_email ), '
';
echo 'is_free_email = ', DisposableEmailChecker::is_free_email( $p_email ), '
';
}
/**
* A debugging function that outputs some statistics about the number of domains in
* each category.
*/
function echo_stats() {
echo 'Forwarding Domains: ' . count( DisposableEmailChecker::$forwarding_domains_array ) . '
';
echo 'Free Domains: ' . count( DisposableEmailChecker::$open_domains_array ) . '
';
echo 'Shredded Domains: ' . count( DisposableEmailChecker::$shredder_domains_array ) . '
';
echo 'Time Bound: ' . count( DisposableEmailChecker::$time_bound_domains_array ) . '
';
echo 'Trash Domains: ' . count( DisposableEmailChecker::$trash_domains_array ) . '
';
}
//
// Private functions, shouldn't be called from outside the class
//
/**
* A helper function that takes in an email address and returns a lower case
* domain.
*
* @param $p_email The email address to extra the domain from.
* @returns The lower case domain or empty string if email not valid.
*/
function _get_domain_from_address( $p_email ) {
$t_domain_pos = strpos( $p_email, '@' );
if ( $t_domain_pos === false ) {
return '';
}
return strtolower( substr( $p_email, $t_domain_pos + 1 ) );
}
}