disposable

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 4 Imported by: 1

README

⭐   the project to show your appreciation. :arrow_upper_right:

anti-disposable-email

Anti Disposable Email Address Checker for Go

If you want to detect if new accounts are using disposable email services, then this is your package.

Installation

go get -u github.com/rocketlaunchr/anti-disposable-email
import "github.com/rocketlaunchr/anti-disposable-email"

Usage

import "github.com/rocketlaunchr/anti-disposable-email"

ParsedEmail, _ := disposable.ParseEmail("rocketlaunchr.cloud@gmail.com")
Output
(disposable.ParsedEmail) {
 Email: (string) (len=21) "rocketlaunchr.cloud@gmail.com",
 Preferred: (string) (len=9) "rocketlaunchr.cloud",
 Normalized: (string) (len=9) "rocketlaunchrcloud",
 Extra: (string) "",
 Disposable: (bool) false,
 Domain: (string) (len=11) "gmail.com",
 LocalPart: (string) (len=9) "rocketlaunchr.cloud"
}

If Disposable is true, then the email address is from a disposable email service.

Normalized

If you want to block duplicate email addresses from your database, then store as a unique-key the Normalized data. See docs.

Update

This package can auto-update the disposable domain list. It uses the regularly updated list from here: https://github.com/disposable-email-domains/disposable-email-domains.

import "github.com/rocketlaunchr/anti-disposable-email"
import "github.com/rocketlaunchr/anti-disposable-email/update"

update.Update(ctx, &disposable.DisposableList)

Other useful packages

  • awesome-svelte - Resources for killing react
  • dataframe-go - Statistics and data manipulation
  • dbq - Zero boilerplate database operations for Go
  • electron-alert - SweetAlert2 for Electron Applications
  • google-search - Scrape google search results
  • igo - A Go transpiler with cool new syntax such as fordefer (defer for for-loops)
  • mysql-go - Properly cancel slow MySQL queries
  • react - Build front end applications using Go
  • remember-go - Cache slow database queries
  • showerglass - A soothing face filter for social applications.
  • testing-go - Testing framework for unit testing

The license is a modified MIT license. Refer to LICENSE file for more details.

© 2022 PJ Engineering and Business Solutions Pty. Ltd.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisposableList = map[string]struct{}{}/* 3418 elements not displayed */

DisposableList is the list of domains that are considered to be from disposable email service providers. See: https://github.com/martenson/disposable-email-domains.

NOTE: To update the list, refer to the 'update' sub-package.

View Source
var ErrInvalidEmail = errors.New("invalid email")

ErrInvalidEmail is returned if the email address is invalid.

Functions

func ValidateDomain

func ValidateDomain(domain string) bool

ValidateDomain returns true if the domain component of an email address is valid. domain must be already lower-case and white-space trimmed. This function only performs a basic check and is not authoritative. For domains containing unicode characters, you must perform punycode conversion beforehand. See: https://godoc.org/golang.org/x/net/idna#ToASCII

Types

type ParsedEmail

type ParsedEmail struct {
	// Email represents the input email (after white-space has been trimmed).
	Email string

	// Preferred represents the local-part in the way the user seems to prefer it.
	// For example if the local-part is case-insensitive, the user may prefer their
	// email address all upper-case even if it does not matter.
	Preferred string

	// Normalized represents the local-part normalized such that it can be
	// compared for uniqueness.
	//
	// For gmail, since john.smith@gmail.com, johnsmith@gmail.com, and JohnSmith@gmail.com
	// are all equivalent, the normalized local-part is 'johnsmith'.
	Normalized string

	// Extra represents extra information that is domain specific.
	//
	// Example: gmail ignores all characters after the first '+' in the local-part.
	//
	// adam+junk@gmail.com => adam@gmail.com (Extra: junk)
	Extra string

	// Disposable is true if the email address is detected to be from
	// a disposable email service.
	//
	// See: https://github.com/martenson/disposable-email-domains
	Disposable bool

	// Domain represents the component after the '@' character.
	// It is lower-cased since it's case-insensitive.
	Domain string

	// LocalPart represents the component before the '@' character.
	LocalPart string
}

ParsedEmail returns a parsed email address.

An email address is made up of 3 components: <local-part>@<domain>. The local-part is case-sensitive according to the specs, but most (if not all) reputable email services will treat it as case-insensitive. The domain is case-insensitive.

func ParseEmail

func ParseEmail(email string, caseSensitive ...bool) (ParsedEmail, error)

ParseEmail parses a given email address. Set caseSensitive to true if you want the local-part to be considered case-sensitive. The default value is false. Basic email validation is performed but it is not comprehensively checked.

See https://github.com/badoux/checkmail for a more robust validation solution.

See also https://davidcel.is/posts/stop-validating-email-addresses-with-regex.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL