{"id":13412673,"url":"https://github.com/go-email-validator/go-email-validator","last_synced_at":"2025-03-14T18:31:58.489Z","repository":{"id":38317918,"uuid":"320356654","full_name":"go-email-validator/go-email-validator","owner":"go-email-validator","description":"📧 Golang Email address validator","archived":true,"fork":false,"pushed_at":"2023-09-15T18:32:58.000Z","size":539,"stargazers_count":51,"open_issues_count":3,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-31T20:51:16.110Z","etag":null,"topics":["disposable","email","email-validation","email-validator","email-verification","email-verifier","go","golang","mail","smtp-validator","validation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-email-validator.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-12-10T18:27:20.000Z","updated_at":"2024-06-25T15:19:42.000Z","dependencies_parsed_at":"2024-01-30T04:55:13.073Z","dependency_job_id":null,"html_url":"https://github.com/go-email-validator/go-email-validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-email-validator%2Fgo-email-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-email-validator%2Fgo-email-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-email-validator%2Fgo-email-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-email-validator%2Fgo-email-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-email-validator","download_url":"https://codeload.github.com/go-email-validator/go-email-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243625160,"owners_count":20321247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["disposable","email","email-validation","email-validator","email-verification","email-verifier","go","golang","mail","smtp-validator","validation"],"created_at":"2024-07-30T20:01:27.652Z","updated_at":"2025-03-14T18:31:57.678Z","avatar_url":"https://github.com/go-email-validator.png","language":"Go","funding_links":[],"categories":["电子邮件","Email","Relational Databases"],"sub_categories":["检索及分析资料库","Search and Analytic Databases","Advanced Console UIs"],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/go-email-validator/go-email-validator.svg)](https://pkg.go.dev/github.com/go-email-validator/go-email-validator)\n[![codecov](https://codecov.io/gh/go-email-validator/go-email-validator/branch/master/graph/badge.svg?token=BC864E3W3X)](https://codecov.io/gh/go-email-validator/go-email-validator)\n[![Go Report](https://goreportcard.com/badge/github.com/go-email-validator/go-email-validator)](https://goreportcard.com/report/github.com/go-email-validator/go-email-validator)\n\n## Library under development (Interfaces may be changed slightly)\n\n## Demo on [rapidapi.com](https://rapidapi.com/maranqz/api/email-validator15)\n\n## Install\n\n```go get -u github.com/go-email-validator/go-email-validator```\n\n## Available validators\n\nusername@domain.part\n\n* [syntaxValidator](pkg/ev/validator_syntax.go)\n  1. `NewSyntaxValidator()` - mail.ParseAddress from built-in library\n  1. `NewSyntaxRegexValidator(emailRegex *regexp.Regexp)` - validation based on regular expression\n* [disposableValidator](pkg/ev/validator_disposable.go) based\n  on [mailchecker](https://github.com/FGRibreau/mailchecker) by default (set is replaceable)\n* [roleValidator](pkg/ev/validator_role.go) bases on [role-based-email-addresses](https://github.com/mixmaxhq/role-based-email-addresses) by default (set is replaceable)\n* [mxValidator](pkg/ev/validator_mx.go)\n* [smtpValidator](pkg/ev/validator_smtp.go)\n\n    to use proxy connection, DialFunc need to be changed in [Checker](pkg/ev/evsmtp/smtp.go). There is [evsmtp.H12IODial](pkg/ev/evsmtp/proxy.go), implementing for [h12w](https://github.com/h12w/socks).\n* [banWordsUsernameValidator](pkg/ev/validator_banwords_username.go) looks for banned words in username\n* [blackListEmailsValidator](pkg/ev/validator_blacklist_email.go) blocked emails from list\n* [blackListValidator](pkg/ev/validator_blacklist_domain.go) blocked emails with domains from black list\n* [whiteListValidator](pkg/ev/validator_whitelist_domain.go) accepts only emails from white list\n* [gravatarValidator](pkg/ev/validator_gravatar.go) check existing of user on gravatar.com\n\n## Usage\n\n### With builder\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/go-email-validator/go-email-validator/pkg/ev\"\n  \"github.com/go-email-validator/go-email-validator/pkg/ev/evmail\"\n)\n\nfunc main() {\n  // create defaults DepValidator with GetDefaultFactories() as list of validators\n  builder := ev.NewDepBuilder(nil).Build()\n  /*\n     to set another list of initial validators\n     builder := NewDepBuilder(\u0026ValidatorMap{\n         ev.ValidatorName: ev.Validator,\n     }).Build()\n  */\n\n  // builder.Set(ev.ValidatorName, NewValidator()) builder\n  // builder.Has(names ...ev.ValidatorName) bool\n  // builder.Delete(names ...ev.ValidatorName) bool\n\n  validator := builder.Build()\n\n  v := validator.Validate(NewInput(evmail.FromString(\"test@evmail.com\")))\n  if !v.IsValid() {\n    panic(\"email is invalid\")\n  }\n\n  fmt.Println(v)\n}\n\n```\n\n### Single validator\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/go-email-validator/go-email-validator/pkg/ev\"\n  \"github.com/go-email-validator/go-email-validator/pkg/ev/evmail\"\n)\n\nfunc main() {\n  var v = ev.NewSyntaxValidator().Validate(ev.NewInput(evmail.FromString(\"some@evmail.here\"))) // ev.ValidationResult\n\n  if !v.IsValid() {\n    panic(\"email is invalid\")\n  }\n\n  fmt.Println(v)\n}\n```\n\n### Addition options\n\nTo set options for different validators, use NewInput(..., NewKVOption(ValidatorName, Options))\n\n```go\nNewInput(\n\tevmail.FromString(\"test@evmail.com\"), \n\tNewKVOption(SMTPValidatorName, evsmtp.NewOptions(evsmtp.OptionsDTO{\n\t\tPort: 465,\n    })),\n)\n```\n\nUse function New...(...) to create structure instead of public.\n\n## How to extend\n\nTo add own validator, just implement [ev.Validator](pkg/ev/validator.go) interface. For validator without dependencies, you can use structure ev.AValidatorWithoutDeps\n\n## Decorators\n\n1. [WarningsDecorator](pkg/ev/decorator_warnings.go) allows moving errors to warnings and change result of `IsValid()` in [ValidationResult](pkg/ev/validator.go).\n1. Cache based on evcahce.Interface, default realization is done for gocache.\n    * [CacheDecorator](pkg/ev/decorator_cache.go) saves result of validator. For caching, you can implement `evcache.Interface` or use [gocache implementation](https://github.com/eko/gocache) by `evcache.NewCache`. See [Test_Cache](pkg/ev/decorator_cache_test.go) as example.\n    * [checkerCacheRandomRCPT](pkg/ev/evsmtp/smtp.go) for caching of RandomRCPTs request. See Test_checkerCacheRandomRCPT_RandomRCPT_RealCache as example.\n\n**Notice**, to use [msgpack](https://github.com/vmihailenco/msgpack) you should have exported fields or implement custom encoding/decoding ([doc](https://msgpack.uptrace.dev/#custom-encodingdecoding))\n\n## Logger\n\nPackage use [zap](https://github.com/uber-go/zap).\n\nTo use logging see in [log package](pkg/log).\nDefault level is zap.ErrorLevel.\n\n## Addition\n\n1. For running workflow locally use [act](https://github.com/nektos/act)\n\n## FAQ\n\n#### Most Internet Service Providers block outgoing SMTP request.\n\nThe [StackOverflow thread](https://stackoverflow.com/questions/18139102/how-to-get-around-an-isp-block-on-port-25-for-smtp) could be helpful.\n\n#### To check smtp in telnet\n\n```\ntelnet\n\nOPEN gmail-smtp-in.l.google.com 25\nEHLO localhost\nMAIL FROM: \u003cuser@example.org\u003e\nrcpt to: \u003csome.email@gmail.com\u003e\nquit\n```\n\n#### Some mail providers could put your ip in spam filter.\n\nFor example:\n1. hotmail.com\n\n## Roadmap\n\n* Tests\n  * Add functional tests\n  * Find way to compare functions in tests\n* Add binary release\n* Check in spamhaus\n* Add misspelled email\n* Add DKIM checking\n* Add linter in pre-hook and ci\n* Do full thread safe library\n* Copy features from [truemail](https://github.com/truemail-rb/truemail)\n    * [Extend MX](https://truemail-rb.org/truemail-gem/#/validations-layers?id=mx-validation)\n      , [rfc5321 section 5](https://tools.ietf.org/html/rfc5321#section-5)\n    * [Host audit features](https://truemail-rb.org/truemail-gem/#/host-audit-features)\n\n## Inspired by\n\n* [EmailValidator](https://github.com/egulias/EmailValidator)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-email-validator%2Fgo-email-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-email-validator%2Fgo-email-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-email-validator%2Fgo-email-validator/lists"}