Hi there,
I would like to check the e-mail address, which the user provided for registration at my site, to see if it is one of those disposable e-mail addresses.
My idea is to have an array called $blacklist with the domains offering random, disposable e-mail addresses, like:
$blacklist = array("yopmail", "faker2","faker3", ... etc );
To simplifise, I just want to check for the name of the domain; not the whole domain. That is, "yopmail" instead of "yopmail.com".
The email $email should then be the string for which I test if any of the items in the array $blacklist is to be found as a substring of my string.
That is, if the user inputs "12345545@yopmail.com" then a function should return true, because "yopmail" is in the array. If none of the array items are a substring of the string $email, then the function should return false.
I have trawled the web, but not found any solution.
What I am looking for is a simple function which parses the e-mail string for the array substrings.
What I have so far is this:
$blacklist = array("yopmail");
function disposable($theEmail) {
foreach ($badInbox as $blacklist) {
if(strpos($badInbox, $theEmail)) {
return true;
}
else return false;
}
}
if(disposable($email)) {
do ...
}
However, even if I test with an e-mail address, which should be banned, the address passes my check.
What is wrong, and how do I get a working function?
I am quite a newbee on php and hope that anyone can help.
Thank you very much in advance.