Please enable JavaScript in your browser.

Overview

This Go Package provides an easy way to call the MailboxValidator 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

Sample Codes

To validate an email address
package main

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

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: %s\n", result.EmailAddress)
	fmt.Printf("Domain: %s\n", result.Domain)
	fmt.Printf("IsFree: %s\n", result.IsFree)
	fmt.Printf("IsSyntax: %s\n", result.IsSyntax)
	fmt.Printf("IsDomain: %s\n", result.IsDomain)
	fmt.Printf("IsSMTP: %s\n", result.IsSMTP)
	fmt.Printf("IsVerified: %s\n", result.IsVerified)
	fmt.Printf("IsServerDown: %s\n", result.IsServerDown)
	fmt.Printf("IsGreylisted: %s\n", result.IsGreylisted)
	fmt.Printf("IsDisposable: %s\n", result.IsDisposable)
	fmt.Printf("IsSuppressed: %s\n", result.IsSuppressed)
	fmt.Printf("IsRole: %s\n", result.IsRole)
	fmt.Printf("IsHighRisk: %s\n", result.IsHighRisk)
	fmt.Printf("IsCatchAll: %s\n", result.IsCatchAll)
	fmt.Printf("MailboxValidatorScore: %s\n", result.MailboxValidatorScore)
	fmt.Printf("TimeTaken: %s\n", result.TimeTaken)
	fmt.Printf("Status: %s\n", result.Status)
	fmt.Printf("CreditsAvailable: %d\n", result.CreditsAvailable)
	fmt.Printf("ErrorCode: %s\n", result.ErrorCode)
	fmt.Printf("ErrorMessage: %s\n", result.ErrorMessage)
}
			

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

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

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: %s\n", result.EmailAddress)
	fmt.Printf("IsDisposable: %s\n", result.IsDisposable)
	fmt.Printf("CreditsAvailable: %d\n", result.CreditsAvailable)
	fmt.Printf("ErrorCode: %s\n", result.ErrorCode)
	fmt.Printf("ErrorMessage: %s\n", result.ErrorMessage)
}
			

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

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

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: %s\n", result.EmailAddress)
	fmt.Printf("IsFree: %s\n", result.IsFree)
	fmt.Printf("CreditsAvailable: %d\n", result.CreditsAvailable)
	fmt.Printf("ErrorCode: %s\n", result.ErrorCode)
	fmt.Printf("ErrorMessage: %s\n", result.ErrorMessage)
}