Skip to content

bobadilla-tech/is-email-disposable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Is Email Disposable

A Go package to detect disposable email addresses using an embedded, automatically-updated blocklist.

Go Reference Go Report Card License

Features

  • πŸš€ Zero dependencies - Pure Go implementation
  • πŸ“¦ Embedded blocklist - No external files needed at runtime
  • ⚑ Fast lookups - O(1) hash map-based detection
  • πŸ”„ Auto-updates - Monthly automated updates via GitHub Actions
  • πŸ§ͺ Well tested - Comprehensive test coverage
  • πŸ’» Simple API - Easy to integrate

Installation

go get github.com/bobadilla-tech/is-email-disposable

Usage

Basic Usage

package main

import (
    "fmt"
    "github.com/bobadilla-tech/is-email-disposable"
)

func main() {
    // Check if an email is disposable
    if disposable.IsDisposable("[email protected]") {
        fmt.Println("This is a disposable email address")
    }

    // Check if a domain is disposable
    if disposable.IsDisposableDomain("10minutemail.com") {
        fmt.Println("This domain is disposable")
    }

    // Get the total count of disposable domains
    count := disposable.Count()
    fmt.Printf("Tracking %d disposable email domains\n", count)
}

API Reference

IsDisposable(email string) bool

Checks if the given email address uses a disposable domain.

disposable.IsDisposable("[email protected]") // returns true
disposable.IsDisposable("[email protected]")    // returns false

The check is case-insensitive:

disposable.IsDisposable("[email protected]") // returns true

IsDisposableDomain(domain string) bool

Checks if the given domain is in the disposable list.

disposable.IsDisposableDomain("tempmail.com") // returns true
disposable.IsDisposableDomain("gmail.com")    // returns false

GetAllDomains() []string

Returns a slice containing all disposable email domains.

domains := disposable.GetAllDomains()
fmt.Printf("Total disposable domains: %d\n", len(domains))

Note: This returns a large list (thousands of domains). Use IsDisposable() or IsDisposableDomain() for most use cases.

Count() int

Returns the total number of disposable email domains in the blocklist.

count := disposable.Count()
fmt.Printf("Blocking %d disposable domains\n", count)

How It Works

  1. Embedded Data: The blocklist is embedded directly into the compiled binary using Go's embed directive
  2. Efficient Lookup: Domains are stored in a hash map for O(1) lookup performance
  3. Auto-Updates: A GitHub Action runs monthly to fetch the latest blocklist and create a PR
  4. Source: The blocklist comes from disposable-email-domains

Testing

Run the tests:

go test -v

Run benchmarks:

go test -bench=.

Example benchmark results:

BenchmarkIsDisposable-8              	10000000	       120 ns/op
BenchmarkIsDisposableDomain-8        	20000000	        85 ns/op
BenchmarkIsDisposableNotFound-8      	10000000	       115 ns/op

Automated Updates

This package includes a GitHub Action that:

  • Runs on the 1st of every month
  • Downloads the latest blocklist from the upstream repository
  • Runs tests to ensure compatibility
  • Creates a pull request with the changes
  • Can also be triggered manually via workflow dispatch

Note: if your repository disables pull requests created by GITHUB_TOKEN, configure either:

  1. Repository Settings β†’ Actions β†’ General β†’ Workflow permissions and enable Allow GitHub Actions to create and approve pull requests, or
  2. A repository secret named BLOCKLIST_UPDATE_TOKEN (PAT) with contents:write and pull_requests:write permissions.

See .github/workflows/update-blocklist.yml for details.

Need More Email Features?

This package provides offline disposable email detection, but if you need additional email-related features, check out Requiems API:

πŸ”— requiems.xyz | πŸ“š Email API Documentation

Requiems provides a comprehensive suite of email-related API services including:

  • Email validation and verification
  • Disposable email detection (cloud-based)
  • Email deliverability checks
  • Domain reputation analysis
  • And more email utilities

Perfect for when you need real-time validation, additional email intelligence, or a cloud-based solution.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

  • Blocklist maintained by disposable-email-domains
  • Inspired by the need for simple, efficient disposable email detection in Go

Related Projects

About

πŸš€ Easily check if an email is disposable in Go (works offline)

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages