A Go package to detect disposable email addresses using an embedded, automatically-updated blocklist.
- π 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
go get github.com/bobadilla-tech/is-email-disposablepackage 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)
}Checks if the given email address uses a disposable domain.
disposable.IsDisposable("[email protected]") // returns true
disposable.IsDisposable("[email protected]") // returns falseThe check is case-insensitive:
disposable.IsDisposable("[email protected]") // returns trueChecks if the given domain is in the disposable list.
disposable.IsDisposableDomain("tempmail.com") // returns true
disposable.IsDisposableDomain("gmail.com") // returns falseReturns 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.
Returns the total number of disposable email domains in the blocklist.
count := disposable.Count()
fmt.Printf("Blocking %d disposable domains\n", count)- Embedded Data: The blocklist is embedded directly into the compiled binary using Go's
embeddirective - Efficient Lookup: Domains are stored in a hash map for O(1) lookup performance
- Auto-Updates: A GitHub Action runs monthly to fetch the latest blocklist and create a PR
- Source: The blocklist comes from disposable-email-domains
Run the tests:
go test -vRun 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
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:
- Repository Settings β Actions β General β Workflow permissions and enable Allow GitHub Actions to create and approve pull requests, or
- A repository secret named
BLOCKLIST_UPDATE_TOKEN(PAT) withcontents:writeandpull_requests:writepermissions.
See .github/workflows/update-blocklist.yml for details.
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.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Blocklist maintained by disposable-email-domains
- Inspired by the need for simple, efficient disposable email detection in Go
- disposable-email-domains - The upstream blocklist source