go-email-validator alternatives and similar packages
Based on the "Email" category.
Alternatively, view go-email-validator alternatives based on common mentions on social networks and blogs.
-
go-simple-mail
Golang package for send email. Support keep alive connection, TLS and SSL. Easy for bulk SMTP. -
Mailchain
Using Mailchain, blockchain users can now send and receive rich-media HTML messages with attachments via a blockchain address. -
truemail-go
๐ Configurable Golang ๐จ email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists. -
go-mail
:incoming_envelope: Simple email interface across multiple service providers (ses, postmark, mandrill, smtp)
InfluxDB - Power Real-Time Data Analytics at Scale
Do you think we are missing an alternative of go-email-validator or a related project?
README
Library under development (Interfaces may be changed slightly)
Demo on rapidapi.com
Install
go get -u github.com/go-email-validator/go-email-validator
Available validators
- [syntaxValidator](pkg/ev/validator_syntax.go)
NewSyntaxValidator()
- mail.ParseAddress from built-in libraryNewSyntaxRegexValidator(emailRegex *regexp.Regexp)
- validation based on regular expression
- [disposableValidator](pkg/ev/validator_disposable.go) based on mailchecker by default (set is replaceable)
- [roleValidator](pkg/ev/validator_role.go) bases on role-based-email-addresses by default (set is replaceable)
- [mxValidator](pkg/ev/validator_mx.go)
[smtpValidator](pkg/ev/validator_smtp.go)
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.
[banWordsUsernameValidator](pkg/ev/validator_banwords_username.go) looks for banned words in username
[blackListEmailsValidator](pkg/ev/validator_blacklist_email.go) blocked emails from list
[blackListValidator](pkg/ev/validator_blacklist_domain.go) blocked emails with domains from black list
[whiteListValidator](pkg/ev/validator_whitelist_domain.go) accepts only emails from white list
[gravatarValidator](pkg/ev/validator_gravatar.go) check existing of user on gravatar.com
Usage
With builder
package main
import (
"fmt"
"github.com/go-email-validator/go-email-validator/pkg/ev"
"github.com/go-email-validator/go-email-validator/pkg/ev/evmail"
)
func main() {
// create defaults DepValidator with GetDefaultFactories() as list of validators
builder := ev.NewDepBuilder(nil).Build()
/*
to set another list of initial validators
builder := NewDepBuilder(&ValidatorMap{
ev.ValidatorName: ev.Validator,
}).Build()
*/
// builder.Set(ev.ValidatorName, NewValidator()) builder
// builder.Has(names ...ev.ValidatorName) bool
// builder.Delete(names ...ev.ValidatorName) bool
validator := builder.Build()
v := validator.Validate(NewInput(evmail.FromString("[email protected]")))
if !v.IsValid() {
panic("email is invalid")
}
fmt.Println(v)
}
Single validator
package main
import (
"fmt"
"github.com/go-email-validator/go-email-validator/pkg/ev"
"github.com/go-email-validator/go-email-validator/pkg/ev/evmail"
)
func main() {
var v = ev.NewSyntaxValidator().Validate(NewInput(evmail.FromString("[email protected]"))) // ev.ValidationResult
if !v.IsValid() {
panic("email is invalid")
}
fmt.Println(v)
}
Addition options
To set options for different validators, use NewInput(..., NewKVOption(ValidatorName, Options))
NewInput(
evmail.FromString("[email protected]"),
NewKVOption(SMTPValidatorName, evsmtp.NewOptions(evsmtp.OptionsDTO{
Port: 465,
})),
)
Use function New...(...) to create structure instead of public.
How to extend
To add own validator, just implement [ev.Validator](pkg/ev/validator.go) interface. For validator without dependencies, you can use structure ev.AValidatorWithoutDeps
Decorators
- [WarningsDecorator](pkg/ev/decorator_warnings.go) allows moving errors to warnings and change result of
IsValid()
in [ValidationResult](pkg/ev/validator.go). - Cache based on evcahce.Interface, default realization is done for gocache.
- [CacheDecorator](pkg/ev/decorator_cache.go) saves result of validator. For caching, you can implement
evcache.Interface
or use gocache implementation byevcache.NewCache
. See [Test_Cache](pkg/ev/decorator_cache_test.go) as example. - [checkerCacheRandomRCPT](pkg/ev/evsmtp/smtp.go) for caching of RandomRCPTs request. See Test_checkerCacheRandomRCPT_RandomRCPT_RealCache as example.
- [CacheDecorator](pkg/ev/decorator_cache.go) saves result of validator. For caching, you can implement
Notice, to use msgpack you should have exported fields or implement custom encoding/decoding (doc)
Logger
Package use zap.
To use logging see in [log package](pkg/log). Default level is zap.ErrorLevel.
Addition
- For running workflow locally use act
FAQ
Most Internet Service Providers block outgoing SMTP request.
The StackOverflow thread could be helpful.
To check smtp in telnet
telnet
OPEN gmail-smtp-in.l.google.com 25
EHLO localhost
MAIL FROM: <[email protected]>
rcpt to: <[email protected]>
quit
Some mail providers could put your ip in spam filter.
For example:
- hotmail.com
Roadmap
- Tests
- Add functional tests
- Find way to compare functions in tests
- Add binary release
- Check in spamhaus
- Add misspelled email
- Add DKIM checking
- Add linter in pre-hook and ci
- Do full thread safe library
- Copy features from truemail