Module: MailShield
- Defined in:
- lib/mailshield.rb,
lib/mailshield/disposable_domains.rb,
lib/mailshield/secure_email_validator.rb
Defined Under Namespace
Classes: DMARCError, DomainNotFoundError, InvalidFormatError, SMTPError, SPFError, SecureEmailValidator, TemporaryDomainError, ValidationError
Constant Summary collapse
- EMAIL_REGEX =
Regex pattern for validating email formats
/\A[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\z/.freeze
- KNOWN_DISPOSABLE_DOMAINS =
Set.new( [ '10mail.org', '10minut.com.pl', '10minut.xyz', '10minutemail.nl', '11163.com', '1secmail.com', '1secmail.net', '1secmail.org', '20minutemail.com', '2chmail.net', '30wave.com', '4warding.net', '55hosting.net', '5july.org', '5ymail.com', '672643.net', '6ip.us', '99.com', 'acentri.com', 'afrobacon.com', 'ahk.jp', 'aiafhg.com', 'airsi.de', 'akgq701.com', 'aleeas.com', 'alienware13.com', 'ama-trans.de', 'amiri.net', 'ano-mail.net', 'anonaddy.com', 'anonmails.de', 'apkmd.com', 'armyspy.com', 'asorent.com', 'augmentationtechnology.com', 'aver.com', 'averdov.com', 'axsup.net', 'b2cmail.de', 'banit.club', 'bearsarefuzzy.com', 'belamail.org', 'bitwhites.top', 'bladesmail.net', 'bobmail.info', 'boxformail.in', 'ccmail.uk', 'ceed.se', 'chammy.info', 'cheaphub.net', 'choco.la', 'choicemail1.com', 'chong-mail.net', 'cocoro.uk', 'cocovpn.com', 'crazymailing.com', 'cream.pink', 'cutradition.com', 'cuvox.de', 'd1yun.com', 'd3p.dk', 'dab.ro', 'dandikmail.com', 'datum2.com', 'dayrep.com', 'desoz.com', 'devnullmail.com', 'digdig.org', 'digitalsanctuary.com', 'dispo.in', 'dispostable.com', 'dndent.com', 'domozmail.com', 'drdrb.com', 'drevo.si', 'dropmail.me', 'dukedish.com', 'durandinterstellar.com', 'e4ward.com', 'eay.jp', 'ee1.pl', 'efxs.ca', 'einmalmail.de', 'einrot.com', 'eintagsmail.de', 'email.com', 'email.it', 'email60.com', 'emailinfive.com', 'emailresort.com', 'emailxfer.com', 'emeraldwebmail.com', 'emlhub.com', 'emlpro.com', 'emltmp.com', 'envy17.com', 'esemay.com', 'ether123.net', 'ethereum1.top', 'ethersports.org', 'evyush.com', 'exdonuts.com', 'express.net.ua', 'eyepaste.com', 'fanclub.pm', 'fangoh.com', 'fantasymail.de', 'fastmail.com', 'fatflap.com', 'fightallspam.com', 'fiifke.de', 'findu.pl', 'fleckens.hu', 'foobarbot.net', 'fr33mail.info', 'freeinbox.email', 'freeml.net', 'fukurou.ch', 'fuwamofu.com', 'fuwari.be', 'gafy.net', 'gambling.com', 'gehensiemirnichtaufdensack.de', 'gelitik.in', 'geronra.com', 'getmails.eu', 'getover.de', 'givememail.club', 'gmatch.org', 'go2vpn.net', 'golemico.com', 'greenhousemail.com', 'guerillamail.biz', 'guerrillamail.com', 'gustr.com', 'haltospam.com', 'hamham.uk', 'harakirimail.com', 'haydoo.com', 'headstrong.de', 'heisei.be', 'herp.in', 'herpderp.nl', 'hidemyass.com', 'hidzz.com', 'hola.org', 'honeys.be', 'honor-8.com', 'hornyalwary.top', 'hostcalls.com', 'hotmai.com', 'hotsoup.be', 'ichigo.me', 'icx.ro', 'ieatspam.eu', 'ige.es', 'imails.info', 'imstations.com', 'in-ulm.de', 'inboxalias.com', 'inkomail.com', 'instaddr.ch', 'interstats.org', 'ip6.li', 'janproz.com', 'jobposts.net', 'jourrapide.com', 'kagi.be', 'katztube.com', 'kbox.li', 'kkmail.be', 'kksm.be', 'klipschx12.com', 'kmail.li', 'koszmail.pl', 'kpay.be', 'kpost.be', 'kulturbetrieb.info', 'labworld.org', 'lee.mx', 'lenovog4.com', 'lgxscreen.com', 'lifetotech.com', 'ligsb.com', 'lillemap.net', 'locanto1.club', 'locantofuck.top', 'lukop.dk', 'macr2.com', 'macromaid.com', 'magim.be', 'mail.darmajaya.ac.id', 'mail.ru', 'mail.tm', 'mail21.cc', 'mailcker.com', 'maildrop.cc', 'maildx.com', 'mailfs.com', 'mailguard.me', 'mailinater.com', 'mailinator.com', 'mailinator.net', 'mailinator.us', 'mailsac.com', 'mailscrap.com', 'mailshell.com', 'mailtechx.com', 'mailtothis.com', 'mama3.org', 'manybrain.com', 'mbox.re', 'meantinc.com', 'mepost.pw', 'merry.pink', 'metalunits.com', 'midiharmonica.com', 'mirai.re', 'mobilevpn.top', 'mofu.be', 'moimoi.re', 'monumentmail.com', 'morsin.com', 'mt2009.com', 'mt2014.com', 'mt2015.com', 'mybitti.de', 'mymail-in.net', 'mymailoasis.com', 'mypacks.net', 'myspamless.com', 'mystvpn.com', 'mytrashmail.com', 'na-cat.com', 'nada.email', 'nagi.be', 'nanonym.ch', 'neko2.net', 'nekochan.fr', 'nervmich.net', 'nextstopvalhalla.com', 'nezdiro.org', 'nezumi.be', 'niseko.be', 'nospamfor.us', 'notmailinator.com', 'ntlhelp.net', 'nurfuerspam.de', 'nutpa.net', 'nypato.com', 'okinawa.li', 'onemail.host', 'onetm.jp', 'online.ms', 'oopi.org', 'ovomail.co', 'owleyes.ch', 'oxopoha.com', 'p33.org', 'pancakemail.com', 'pavilionx2.com', 'payperex2.com', 'pecinan.net', 'pingir.com', 'placebomail10.com', 'plw.me', 'porsh.net', 'pratikmail.com', 'pratikmail.org', 'prin.be', 'privy-mail.de', 'pro-tag.org', 'projectcl.com', 'psh.me', 'put2.net', 'putthisinyourspamdatabase.com', 'qtum-ico.com', 'quickemail.info', 'quicksend.ch', 'rabin.ca', 'rapt.be', 'reallymymail.com', 'recode.me', 'redfeathercrow.com', 'reftoken.net', 'rhyta.com', 'rootfest.net', 'royal.net', 'ruru.be', 'safetymail.info', 'schrott-email.de', 'sendnow.win', 'sendspamhere.com', 'senseless-entertainment.com', 'sexyalwasmi.top', 'shalar.net', 'sharklasers.com', 'shieldedmail.com', 'shieldemail.com', 'shipfromto.com', 'shrib.com', 'sika3.com', 'simaenaga.com', 'simplelogin.co', 'sinaite.net', 'slaskpost.se', 'sofia.re', 'sogetthis.com', 'spamdecoy.net', 'spamhereplease.com', 'spamhole.com', 'stayhome.li', 'storiqax.top', 'storj99.com', 'storj99.top', 'stromox.com', 'superrito.com', 'supersave.net', 'suremail.info', 'svk.jp', 'tapi.re', 'teleworm.us', 'temp-mail.org', 'tempail.com', 'tempemail.net', 'tempmail.dev', 'tempmail2.com', 'tempmailer.com', 'tempmailo.com', 'tensi.org', 'testudine.com', 'thankyou2010.com', 'thisisnotmyrealemail.com', 'throwam.com', 'tilien.com', 'tmail.ws', 'tokem.co', 'topless-new-world.com', 'topmail.com', 'torba.cc', 'trickmail.net', 'trickmail.org', 'trixtrux1.com', 'truckeremail.net', 'tryalert.com', 'turual.com', 'twddos.com', 'unmail.ru', 'uploadnolimit.com', 'uw5t6ds54.com', 'ventolin.org', 'vintomaper.com', 'vmailcloud.com', 'vubby.com', 'vuiy.pw', 'warpmail.net', 'watch-harry-potter.com', 'watchfulli.com', 'wep68.com', 'wh4f.org', 'willhackforfood.biz', 'winbroadband.co.uk', 'workshop-liberal.com', 'wronghead.com', 'wwwmail.win', 'x24.com', 'xn--9kq967o.com', 'xn--cg7bx4b4x1b.com', 'xsynergy.top', 'xxhamsterxx.com', 'yepmail.net', 'yesspam.com', 'yo-site.com', 'yogotemail.com', 'yopmail.fr', 'yopmail.gq', 'yopmail.net', 'yopmail.org', 'yourinbox.email', 'yuurok.com', 'zainmax.net', 'ze.gy', 'zipmail.com', 'zoemail.net', 'zombie-hive.com', 'zsero.com', 'zumrot.com' ] )
Class Attribute Summary collapse
-
.blacklist ⇒ Object
Returns the value of attribute blacklist.
-
.dns_cache ⇒ Object
Returns the value of attribute dns_cache.
-
.smtp_cache ⇒ Object
Returns the value of attribute smtp_cache.
-
.whitelist ⇒ Object
Returns the value of attribute whitelist.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Configuration method for initializing and yielding settings.
- .email_exists?(email) ⇒ Boolean
- .valid_format?(email) ⇒ Boolean
-
.validate_email(email) ⇒ Object
Validate the structure and existence of the provided email.
- .validate_known_disposal_domain?(domain) ⇒ Boolean
Class Attribute Details
.blacklist ⇒ Object
Returns the value of attribute blacklist.
24 25 26 |
# File 'lib/mailshield.rb', line 24 def blacklist @blacklist end |
.dns_cache ⇒ Object
Returns the value of attribute dns_cache.
24 25 26 |
# File 'lib/mailshield.rb', line 24 def dns_cache @dns_cache end |
.smtp_cache ⇒ Object
Returns the value of attribute smtp_cache.
24 25 26 |
# File 'lib/mailshield.rb', line 24 def smtp_cache @smtp_cache end |
.whitelist ⇒ Object
Returns the value of attribute whitelist.
24 25 26 |
# File 'lib/mailshield.rb', line 24 def whitelist @whitelist end |
Class Method Details
.configure {|_self| ... } ⇒ Object
Configuration method for initializing and yielding settings
27 28 29 30 |
# File 'lib/mailshield.rb', line 27 def configure initialize_lists yield self if block_given? end |
.email_exists?(email) ⇒ Boolean
47 48 49 |
# File 'lib/mailshield.rb', line 47 def email_exists?(email) smtp_verify_email(email) end |
.valid_format?(email) ⇒ Boolean
51 52 53 |
# File 'lib/mailshield.rb', line 51 def valid_format?(email) valid_email_format?(email) end |
.validate_email(email) ⇒ Object
Validate the structure and existence of the provided email
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mailshield.rb', line 33 def validate_email(email) reset_caches domain = extract_domain(email) return { valid: false, reason: 'Email domain is blacklisted.' } if blacklist && blacklist.include?(domain) if whitelist && !whitelist.empty? && !whitelist.include?(domain) return { valid: false, reason: 'Email domain is not whitelisted.' } end # Perform comprehensive validation checks perform_validations(email, domain) end |
.validate_known_disposal_domain?(domain) ⇒ Boolean
90 91 92 |
# File 'lib/mailshield/disposable_domains.rb', line 90 def validate_known_disposal_domain?(domain) raise TemporaryDomainError, 'Temporary / Disposal Email.' if KNOWN_DISPOSABLE_DOMAINS.include?(domain) end |