emailaddress

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 6 Imported by: 0

README

GoDoc Build codecov Go Report Status release

emailaddress.Check()

This package contains two functions to check email addresses.

An email address name must respect rules presented in https://en.wikipedia.org/wiki/Email_address.

The emailaddress.Check function ensures that the email address respect those rules. If not, it returns an error explaining the detected problem. This function accepts emails without a domain like "root" which is valid on unix systems.

The emailaddress.CheckWithDNS() calls Check and also checks that the domain after the last @ is an existing domain accepting emails. With this call the email "root" is invalid since it has no domain accepting emails.

Prerequisites

The package has no prerequisites. It depends on github.com/chmike/domain@v1.0.0 to verify domain names.

Installation

To install or update this package use the instruction:

go get -u "github.com/chmike/emailaddress"

Usage examples

The Check function can be used to check the validity of host or domain names.

import "github.com/chmike/emailaddress"

. . . 

emailAddress := "foo@example.com"
if err := emailaddress.Check(emailAddress); if err != nil {
    log.Fatalf("invalid email address '%s': %v", emailAddress, err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(email string) error

Check returns an error if the email address is not syntactically valid.

func CheckWithDNS added in v1.1.0

func CheckWithDNS(email string) error

CheckWithDNS checks the email validity and also checks that the domain after the last @ is an existing domain that acceptes mails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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