<?php

namespace App\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;

class NotDisposableEmail implements ValidationRule
{
    // Top disposable/throwaway email domains
    private const BLOCKED = [
        '0-mail.com','0815.ru','0clickemail.com','0wnd.net','0wnd.org','10minutemail.com',
        '10minutemail.net','10minutemail.org','10minutemail.de','10mail.org','20minutemail.com',
        '2prong.com','30minutemail.com','33mail.com','3d-painting.com','4warding.com',
        'amilegit.com','anonbox.net','anonymail.net','anonymbox.com','antichef.com',
        'antichef.net','antireg.com','antispam.de','antispammail.de','armyspy.com',
        'baxomale.ht.cx','beefmilk.com','bigstring.com','binkmail.com','bio-muesli.net',
        'bobmail.info','bodhi.lawlita.com','bofthew.com','bootybay.de','bossmail.de',
        'bouncr.com','breakthru.com','brefmail.com','broadbandninja.com','bsnow.net',
        'bugmenot.com','bumpymail.com','casualdx.com','centermail.com','centermail.net',
        'chacuo.net','chammy.info','childsavetrust.org','chogmail.com','choplife.com',
        'clixser.com','cmail.net','coiico.com','cool.fr.nf','correo.blogos.net',
        'crapmail.org','crossroadsmail.com','curryworld.de','cust.in','dacoolest.com',
        'dandikmail.com','dayrep.com','dcemail.com','deadaddress.com','deadletter.ga',
        'deagot.com','dealja.com','despam.it','devnullmail.com','dfgh.net',
        'digitalsanctuary.com','discardmail.com','discardmail.de','disposableaddress.com',
        'disposableinbox.com','disposablemail.net','disposablemail.org','disposablemail.top',
        'dispostable.com','dk4f9h7y.fun','dodgeit.com','dodgit.com','donemail.ru',
        'dontreg.com','dontsendmespam.de','drdrb.com','drdrb.net','dropmail.me',
        'dumpandfuck.com','dumpmail.de','dumpyemail.com','e4ward.com','easytrashmail.com',
        'email60.com','emailfake.com','emailias.com','emailigo.com','emailinfive.com',
        'emailisvalid.com','emaillime.com','emailmiser.com','emailna.com','emailnax.com',
        'emailnew.com','emailo.pro','emailondeck.com','emailthe.net','emailtmp.com',
        'emailwarden.com','emailx.at.hm','emailxfer.com','emeil.in','emeil.ir',
        'emlhub.com','emltmp.com','enterto.com','ephemail.net','etranquil.com',
        'evopo.com','explodemail.com','express.net.ua','eyepaste.com','fakeinbox.com',
        'fakeinformation.com','fakemail.fr','fakemailgenerator.com','fakemail.net',
        'fastacura.com','fastchevy.com','fastchrysler.com','fastkawasaki.com','fastmazda.com',
        'fastmitsubishi.com','fastnissan.com','fastsubaru.com','fastsuzuki.com','fasttoyota.com',
        'fastyamaha.com','fatflap.com','fdcserver.net','fightallspam.com','filzmail.com',
        'fixmail.tk','fizmail.com','fleckens.hu','flemail.com','frapmail.com',
        'friendlymail.co.uk','fuckingduh.com','fudgerub.com','fux0ringduh.com','fyxm.net',
        'garliclife.com','gehensiemirnichtaufdensack.de','gelitik.in','get2mail.fr',
        'getairmail.com','getonemail.com','giantmail.de','girlsundertheinfluence.com',
        'gishpuppy.com','gmailnew.com','goemailgo.com','gorillaswithdirtyarmpits.com',
        'gotmail.net','gotmail.org','gowikibooks.com','gowikicampus.com','gowikicars.com',
        'gowikifilms.com','gowikigames.com','gowikimusic.com','gowikinetwork.com',
        'gowikitravel.com','grr.la','guerillamail.biz','guerillamail.com','guerillamail.de',
        'guerillamail.info','guerillamail.net','guerillamail.org','guerrillamail.biz',
        'guerrillamail.com','guerrillamail.de','guerrillamail.info','guerrillamail.net',
        'guerrillamail.org','guerrillamailblock.com','gustr.com','h.mintemail.com',
        'haltospam.com','haqed.com','harakirimail.com','hat-geld.de','hatespam.org',
        'herp.in','hidemail.de','high.net','hmamail.com','hopemail.biz',
        'hulapla.de','ieatspam.eu','ieatspam.info','ieh-mail.de','ihateyoualot.info',
        'iheartspam.org','ikbenspamvrij.nl','imails.info','inboxclean.com','inboxclean.org',
        'incognitomail.net','incognitomail.org','insorg.org','internet-e-mail.de','jetable.fr',
        'jetable.net','jetable.org','jnxjn.com','joggly.com','junk.to',
        'justamail.net','kasmail.com','kaspop.com','killmail.com','killmail.net',
        'klzlk.com','koszmail.pl','kurzepost.de','laoeq.com','lavabit.com',
        'letthemeatspam.com','lhsdv.com','lifebyfood.com','lol.ovpn.to','lookugly.com',
        'lopl.co.cc','lortemail.dk','lovemeleaveme.com','lr78.com','lukop.dk',
        'm4ilweb.info','maboard.com','mail-filter.com','mail-temporaire.com','mail.by',
        'mail1a.de','mail2rss.org','mail333.com','mailbidon.com','mailblocks.com',
        'mailbucket.org','mailchop.com','maileater.com','maileimer.de','mailexpire.com',
        'mailfa.tk','mailforspam.com','mailfree.ga','mailguard.me','mailimate.com',
        'mailinatar.com','mailinater.com','mailinator.com','mailinator.net','mailinator.org',
        'mailinator.us','mailinator2.com','mailincubator.com','mailismagic.com','mailjunk.cf',
        'mailjunk.ga','mailjunk.gq','mailjunk.ml','mailjunk.tk','mailme.gq',
        'mailme.ir','mailme24.com','mailmetrash.com','mailmoat.com','mailms.com',
        'mailnull.com','mailpick.biz','mailproxsy.com','mailquack.com','mailrock.biz',
        'mailscrap.com','mailseal.de','mailshell.com','mailsiphon.com','mailslapping.com',
        'mailslite.com','mailsoul.com','mailsucker.net','mailtemp.info','mailtome.de',
        'mailtothis.com','mailtrash.net','mailtv.net','mailzilla.com','makemetheking.com',
        'mbx.cc','mega.zik.dj','meinspamschutz.de','meltmail.com','messagebeamer.de',
        'mezimages.net','mintemail.com','moncourrier.fr.nf','monemail.fr.nf','monmail.fr.nf',
        'msa.minsmail.com','msgos.com','mt2014.com','mt2015.com','mucincanon.com',
        'mucke.de','mugglenet.com','myfastmail.com','mymailoasis.com','mynetstore.de',
        'netzidiot.de','neverbox.com','nice-4u.com','nincsmail.hu','nmail.cf',
        'nnot.net','nobulk.com','noclickemail.com','nodezine.com','nomail.pw',
        'nomail.xl.cx','nomail2me.com','nomoremail.net','nospam.ze.tc','nospam4.us',
        'nospamfor.us','nospammail.net','nospamthanks.info','notmailinator.com','nowmymail.com',
        'odnorazovoe.ru','onewaymail.com','online.ms','opayq.com','ordinaryamerican.net',
        'ovpn.to','owlpic.com','pecinan.com','pecinan.net','pecinan.org',
        'pepbot.com','pfui.ru','pimpedupmyspace.com','plexolan.de','pookmail.com',
        'privacy.net','proxymail.eu','prtnx.com','purelymail.com','putthisinyourspamdatabase.com',
        'qq.com.de','quickinbox.com','rcpt.at','recode.me','recursor.net',
        'regbypass.com','rklips.com','rmqkr.net','rppkn.com','rtrtr.com',
        'runbox.com','s0ny.net','safe-mail.net','safetymail.info','safetypost.de',
        'sandelf.de','saynotospams.com','schafmail.de','schrott-email.de','secretemail.de',
        'secure-mail.biz','sexyalwasmi.top','sharedmailbox.org','sharklasers.com','shieldedmail.com',
        'shiftmail.com','shitmail.de','shitmail.me','shitmail.org','shitware.nl',
        'shortmail.net','sibmail.com','skeefmail.com','slaskpost.se','slopsbox.com',
        'smellfear.com','snakemail.com','sneakemail.com','snkmail.com','sofimail.com',
        'sogetthis.com','sohu.com.de','soisz.com','spam.la','spam.org.tr',
        'spam.su','spam4.me','spamavert.com','spambob.com','spambob.net',
        'spambob.org','spambog.com','spambog.de','spambog.ru','spambox.info',
        'spambox.us','spamcannon.com','spamcannon.net','spamcero.com','spamcon.org',
        'spamcorptastic.com','spamcowboy.com','spamcowboy.net','spamcowboy.org','spamday.com',
        'spamex.com','spamfree.eu','spamfree24.de','spamfree24.eu','spamfree24.info',
        'spamfree24.net','spamfree24.org','spamgourmet.com','spamgourmet.net','spamgourmet.org',
        'spamherelots.com','spamhereplease.com','spamhole.com','spamify.com','spaminator.de',
        'spamkill.info','spaml.com','spaml.de','spammotel.com','spamoff.de',
        'spamsalad.in','spamslicer.com','spamspot.com','spamstack.net','spamthis.co.uk',
        'spamthisplease.com','spamtrail.com','spamtroll.net','speed.1s.fr','speedymail.net',
        'spoofmail.de','super-auswahl.de','supergreatmail.com','supermailer.jp','superrito.com',
        'superstachel.de','suremail.info','sweetxxx.de','tafmail.com','tagyourself.com',
        'teleworm.com','teleworm.us','temp-mail.io','temp-mail.org','temp-mail.ru',
        'temp.bartbot.com','tempail.com','tempalias.com','tempe-mail.com','tempemailaddress.com',
        'tempinbox.co.uk','tempinbox.com','tempmail.it','tempmail.net','tempmail.us',
        'tempmail2.com','tempomail.fr','temporaryemail.net','temporaryemail.us','temporaryforwarding.com',
        'temporaryinbox.com','temporarymail.org','tempsky.com','thankyou2010.com','thc.st',
        'thelimestones.com','thisisnotmyrealemail.com','throam.com','throwam.com','throwaway.email',
        'throwam.com','throwaway.email','throwam.com','tilien.com','tinyurl24.com',
        'tmailinator.com','toiea.com','toomail.biz','top9top.com','tradermail.info',
        'trash-amil.com','trash-mail.at','trash-mail.com','trash-mail.de','trash-mail.io',
        'trash-mail.net','trash2009.com','trash2010.com','trash2011.com','trashcanmail.com',
        'trashdevil.com','trashdevil.de','trashemail.de','trashimail.com','trashmail.at',
        'trashmail.com','trashmail.es','trashmail.io','trashmail.me','trashmail.net',
        'trashmail.org','trashmailer.com','trashpanda.de','trashymail.com','trillianpro.com',
        'turual.com','twinmail.de','tyldd.com','uggsrock.com','upliftnow.com',
        'uroid.com','username.e4ward.com','venompen.com','veryrealemail.com','vidchart.com',
        'viditag.com','viewcastmedia.com','viewcastmedia.net','viewcastmedia.org','vomoto.com',
        'vubby.com','walala.org','watch-harry-potter.com','wetrainbayarea.com','wetrainbayarea.org',
        'wilemail.com','willhackforfood.biz','willselfdestruct.com','wmail.cf','wolfsmail.tk',
        'wuzupmail.net','xagloo.com','xemaps.com','xents.com','xMailer.net',
        'xmaily.com','xn--9kq967o.com','xoxox.cc','xperiae5.com','xyzfree.net',
        'yahomail.org','yapped.net','yepmail.net','yourdomain.com','yopmail.com',
        'yopmail.fr','yopmail.net','youremail.cf','yourewronghello.com','z1p.biz',
        'za.com','zippymail.info','zoemail.net','zoemail.org','zomg.info',
        'zxcv.com','zxcvbnm.com','zzz.com',
    ];

    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        $domain = strtolower(trim(substr(strrchr($value, '@'), 1)));

        if (in_array($domain, self::BLOCKED, true)) {
            $fail('Registrations from disposable email addresses are not allowed.');
        }
    }
}
