Disabling Throwaway eMail Addresses


PLEASE NOTE:
Before you use this tutorial, please know that directly within aMember CP is an option to ban any email address you want, including the ability to use wildcards. For example: To disable customers signing up using a freemail.com email address, you can simply enter %@freemail.com inside the “Configuration -> Blocking IP/E-Mail -> E-mail Address” area.

PLEASE NOTE: See bottom of post for massive list of free email domain names.

As an avid aMember Pro user myself, I have come across this question many times – “How do I disallow throw-away email accounts?”, so, I decided to write up a quick tutorial on exactly how this can be done in less than a minute.

If you’re using aMember Pro and you want to stop subscribers from signing up using a throw away email address, simply follow the guide below to do just that.

1. Add the following to your “/application/configs/site.php” file

Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, function (Am_Event_ValidateSavedForm $e) {
    $form = $e->getForm();
    $vars = $form->getValue();
    if (isset($vars['email'])
        && preg_match('/.*?@(.*)$/i', $vars['email'], $m)
        && in_array($m[1], ['gmail.com', 'hotmail.com'])) {
        $e->addError('Sorry, that email address appears to be from an unallowed email domain.');
    }
});

2. In line 6, change gmail.com and hotmail.com domains to the email domains you wish to block.

3. Add as many domains as you need by inserting additional domains to the array on line 6.

Example:

Line 6:

&& in_array($m[1], ['gmail.com', 'hotmail.com'])) {

Now becomes:

&& in_array($m[1], ['gmail.com', 'hotmail.com', 'domain3.com', 'domain4.com', 'domain5.com'])) {

Here’s a few throw-away email providers to help get you started. And you’ll probably want to check back often as I will continue to add additional domains as I come across them.

Please Note: I do not recommend adding them all, obviously, as doing so could cause serious loading issues.

If you find any of my aMember Pro tutorials or articles useful, or have any questions related to the aMember Pro system, please feel free to post a comment (below) or contact me anytime using my online help desk. I check these pages frequently and will reply as soon as I can.

PLEASE NOTE:
Since many have asked, if you wish to thank me financially, you may do so by "paying it forward" with a donation to a very worthy cause. Alternatively, if you'll be purchasing any additional aMember Pro licenses or any of their add-on modules (plugins), please consider clicking here to purchase using my affiliate ID in which case I will earn a referral fee.


RELATED POSTS

• Creating a Drip-Fed System for Your Member Area [COMING SOON]
Manually Backing Up Your aMember Database
Creating A "Sticky Sidebar" on aMember Cart Pages
Self Testing A Custom Purchasing Functionality
Display Notifications on ALL aMember Pages
Protecting Content: Any Product vs All Registered Customers
Receive Notifications of Illegal Admin Access Attempts
Changing the Resource Block Search Bar Setting
Disabling Throwaway eMail Addresses

Leave a Reply