Skip to content

Adarsh-jaiss/mailify

Repository files navigation

Mailify

Mailify is a Go package for validating email addresses by checking their format, verifying the existence of MX records for the domain, and attempting to connect to the mail servers using SMTP.

Installation

To install the package, run:

go get github.com/adarsh-jaiss/mailify

Usage

Creating a Client

To create a new client, use the NewClient function:

client, err := mailify.NewClient("[email protected]")
if err != nil {
    log.Fatalf("Failed to create mailify client: %v", err)
}

Validating an Email Address

To validate an email address, use the ValidateEmail method:

result, err := client.ValidateEmail("[email protected]")
if err != nil {
    log.Fatalf("Failed to validate email: %v", err)
}

fmt.Println("Validation result:", client.FormatValidationResult("[email protected]", result))

Getting Mail Servers

To get the mail servers for a domain, use the GetMailServers method:

mailServers, err := client.GetMailServers("example.com")
if err != nil {
    log.Fatalf("Failed to get mail servers: %v", err)
}

fmt.Println("Mail servers:", mailServers)

To get the mail servers for a recipient email, use the GetMailServersFromReceipientEmail method:

mailServers, err := client.GetMailServersFromReceipientEmail("[email protected]")
if err != nil {
    log.Fatalf("Failed to get mail servers: %v", err)
}

fmt.Println("Mail servers:", mailServers)

Example

Here is a complete example demonstrating how to use the package : check examples

About

A go library for mx lookup and validating email address

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages