https://github.com/cameronnewman/go-emailvalidation
a simple Go library for email address validation
https://github.com/cameronnewman/go-emailvalidation
email-validation emailvalidation format golang golang-library golang-package host mail mailbox user
Last synced: 5 months ago
JSON representation
a simple Go library for email address validation
- Host: GitHub
- URL: https://github.com/cameronnewman/go-emailvalidation
- Owner: cameronnewman
- License: mit
- Created: 2018-07-26T05:45:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-16T21:51:23.000Z (about 1 year ago)
- Last Synced: 2025-11-22T15:00:01.223Z (7 months ago)
- Topics: email-validation, emailvalidation, format, golang, golang-library, golang-package, host, mail, mailbox, user
- Language: Go
- Homepage:
- Size: 99.6 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# go-emailvalidation
[![Build][1]][2]
[![GoDoc][3]][4]
[![Go Report Card][5]][6]
[![FOSSA Status][9]][10]
[1]: https://github.com/cameronnewman/go-emailvalidation/workflows/pipeline/badge.svg
[2]: https://github.com/cameronnewman/go-emailvalidation/actions/workflows/pipeline.yml/badge.svg
[3]: https://godoc.org/github.com/cameronnewman/go-emailvalidation?status.svg
[4]: https://godoc.org/github.com/cameronnewman/go-emailvalidation
[5]: https://goreportcard.com/badge/github.com/cameronnewman/go-emailvalidation
[6]: https://goreportcard.com/report/github.com/cameronnewman/go-emailvalidation
[9]: https://app.fossa.io/api/projects/git%2Bgithub.com%2Fcameronnewman%2Fgo-emailvalidation.svg?type=shield
[10]: https://app.fossa.io/projects/git%2Bgithub.com%2Fcameronnewman%2Fgo-emailvalidation?ref=badge_shield
## Purpose
Simple email validation package. Package supports either fast email validation via
RFC compliant regex OR slower recursive DNS lookup. DNS validation checks for
valid NS & MX records using the local DNS settings.
## Supported versions
The current version is v3
Please import via go modules `github.com/cameronnewman/go-emailvalidation/v3`.
## Usage
```golang
package main
import (
"fmt"
email "github.com/cameronnewman/go-emailvalidation/v3"
)
func main() {
emailAddress := "John.Snow@gmaiiiiiiillllll.com"
// Run all checks, including validating the format along with DNS lookups which
// may be slower depending on your DNS server performance
err := email.Validate(emailAddress)
if err != nil {
fmt.Println(err)
}
// Checks the format - this function performs no network
// operations and is very fast
err = email.ValidateFormat(emailAddress)
if err != nil {
fmt.Println(err)
}
// Checks domain NS & MX, along with format validation
err = email.ValidateDomainRecords(emailAddress)
if err != nil {
fmt.Println(err)
}
// Normalize email address for storage
address := email.Normalize(emailAddress)
fmt.Println(address)
}
```
## Issues
* None
## License
MIT Licensed