validatemail

package module
v0.0.0-...-5309ca4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2018 License: MIT Imports: 6 Imported by: 0

README

Simple Validate Email for Go

Usage

###1# Format

func main() {
	err := validatemail.ValidateFormat("*!&^4 %@@gmail.com")
	if err != nil {
		fmt.Println(err)
	}
}

output: invalid format

###2# Domain

func main() {
	err := validatemail.ValidateHost("email@x-lazycious-domain.com")
	if err != nil {
		fmt.Println(err)
	}
}

output: unresolvable host

###3# User

func main() {
	err := validatemail.ValidateHost("unknown-user-129083726@gmail.com")
	if smtpErr, ok := err.(validatemail.SmtpError); ok && err != nil {
		fmt.Printf("Code: %s, Msg: %s", smtpErr.Code(), smtpErr)
	}
}

output: Code: 550, Msg: 550 5.1.1 The email account that you tried to reach does not exist.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadFormat        = errors.New("invalid format")
	ErrUnresolvableHost = errors.New("unresolvable host")
)

Functions

func ValidateFormat

func ValidateFormat(email string) error

func ValidateHost

func ValidateHost(email string) error

Types

type SmtpError

type SmtpError struct {
	Err error
}

func NewSmtpError

func NewSmtpError(err error) SmtpError

func (SmtpError) Code

func (e SmtpError) Code() string

func (SmtpError) Error

func (e SmtpError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL