Please enable JavaScript in your browser.

Overview

This Go Package provides an easy way to call the MailboxValidator Email Validation API which validates if an email address is a valid one.

NOTE: An API key will be given to you when you signup for any of our API plans. This package will require that API key to function.


Installation

go get github.com/mailboxvalidator/mailboxvalidator-go/v2

Sample Codes

To validate an email address
package main

import (
	"fmt"
	"github.com/mailboxvalidator/mailboxvalidator-go/v2"
)

func main() {
	mailboxvalidator.SetAPIKey("PASTE_YOUR_API_KEY_HERE")
	
	result, err := mailboxvalidator.ValidateEmail("example@example.com")
	
	if err != nil {
		panic(err.Error())
	}
	
	if result.ErrorMessage != "" {
		panic(result.ErrorMessage)
	}
	
	fmt.Printf("EmailAddress: %+v\n", result.EmailAddress)
	fmt.Printf("Domain: %+v\n", result.Domain)
	fmt.Printf("IsFree: %+v\n", result.IsFree)
	fmt.Printf("IsSyntax: %+v\n", result.IsSyntax)
	fmt.Printf("IsDomain: %+v\n", result.IsDomain)
	fmt.Printf("IsSMTP: %+v\n", result.IsSMTP)
	fmt.Printf("IsVerified: %+v\n", result.IsVerified)
	fmt.Printf("IsServerDown: %+v\n", result.IsServerDown)
	fmt.Printf("IsGreylisted: %+v\n", result.IsGreylisted)
	fmt.Printf("IsDisposable: %+v\n", result.IsDisposable)
	fmt.Printf("IsSuppressed: %+v\n", result.IsSuppressed)
	fmt.Printf("IsRole: %+v\n", result.IsRole)
	fmt.Printf("IsHighRisk: %+v\n", result.IsHighRisk)
	fmt.Printf("IsCatchAll: %+v\n", result.IsCatchAll)
	fmt.Printf("MailboxValidatorScore: %+v\n", result.MailboxValidatorScore)
	fmt.Printf("TimeTaken: %+v\n", result.TimeTaken)
	fmt.Printf("Status: %+v\n", result.Status)
	fmt.Printf("CreditsAvailable: %+v\n", result.CreditsAvailable)
	fmt.Printf("ErrorCode: %+v\n", result.ErrorCode)
	fmt.Printf("ErrorMessage: %+v\n", result.ErrorMessage)
}

To check if an email is from a disposable email provider
package main

import (
	"fmt"
	"github.com/mailboxvalidator/mailboxvalidator-go/v2"
)

func main() {
	mailboxvalidator.SetAPIKey("PASTE_YOUR_API_KEY_HERE")
	
	result, err := mailboxvalidator.DisposableEmail("example@example.com")
	
	if err != nil {
		panic(err.Error())
	}
	
	if result.ErrorMessage != "" {
		panic(result.ErrorMessage)
	}
	
	fmt.Printf("EmailAddress: %+v\n", result.EmailAddress)
	fmt.Printf("IsDisposable: %+v\n", result.IsDisposable)
	fmt.Printf("CreditsAvailable: %+v\n", result.CreditsAvailable)
	fmt.Printf("ErrorCode: %+v\n", result.ErrorCode)
	fmt.Printf("ErrorMessage: %+v\n", result.ErrorMessage)
}

To check if an email is from a free email provider
package main

import (
	"fmt"
	"github.com/mailboxvalidator/mailboxvalidator-go/v2"
)

func main() {
	mailboxvalidator.SetAPIKey("PASTE_YOUR_API_KEY_HERE")
	
	result, err := mailboxvalidator.FreeEmail("example@example.com")
	
	if err != nil {
		panic(err.Error())
	}
	
	if result.ErrorMessage != "" {
		panic(result.ErrorMessage)
	}
	
	fmt.Printf("EmailAddress: %+v\n", result.EmailAddress)
	fmt.Printf("IsFree: %+v\n", result.IsFree)
	fmt.Printf("CreditsAvailable: %+v\n", result.CreditsAvailable)
	fmt.Printf("ErrorCode: %+v\n", result.ErrorCode)
	fmt.Printf("ErrorMessage: %+v\n", result.ErrorMessage)
}

Related Videos