Sign Up Free

Go Email Verification SDK — Verify Emails in Go

Everything you need to integrate email verification into your application.

Getting Started

The official Go SDK requires Go 1.18+, has zero external dependencies using only the standard library, supports context cancellation, custom HTTP clients, and concurrent-safe usage.

Install with go get and verify with idiomatic Go patterns. Supports context.Context for timeouts and cancellation. For web-based verification, visit our email verifier.

Code Example

go get github.com/ecomtechbd/ev-go

package main

import (
    "context"
    "fmt"
    ev "github.com/ecomtechbd/ev-go"
)

func main() {
    client := ev.NewClient("YOUR_API_KEY")

    result, err := client.Verify(context.Background(), "user@example.com")
    if err != nil {
        fmt.Println("Error:", err)
        return
    }

    fmt.Println("Status:", result.Status)        // "deliverable"
    fmt.Println("Score:", result.Score)           // 95
    fmt.Println("Disposable:", result.Disposable) // false
}

Authentication & Setup

Install: go get github.com/ecomtechbd/ev-go. Set EV_API_KEY env var or pass directly. The client is safe for concurrent use across goroutines.

Getting Started

Install the Go email verification SDK by running go get github.com/ecomtechbd/ev-go in your module directory. The package requires Go 1.18 or higher and has zero external dependencies, relying entirely on the Go standard library for HTTP communication, JSON parsing, and cryptographic operations. The module follows semantic versioning and is available through the Go module proxy for fast, reliable downloads.

After installation, create a new client using ev.NewClient() with your API key. You can also set the EV_API_KEY environment variable and call ev.NewClientFromEnv() for automatic key resolution. The client constructor accepts functional options for configuring timeout, maximum retries, sandbox mode, a custom HTTP client, and a custom base URL. The resulting client is safe for concurrent use across multiple goroutines and internally manages connection pooling via Go's http.Transport. All verification methods accept a context.Context as their first parameter, supporting timeout, cancellation, and deadline propagation throughout your application.

Code Examples

Single Email Verification

package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "time"

    ev "github.com/ecomtechbd/ev-go"
)

func main() {
    client := ev.NewClient(os.Getenv("EV_API_KEY"),
        ev.WithTimeout(30*time.Second),
        ev.WithMaxRetries(3),
    )

    ctx := context.Background()
    result, err := client.Verify(ctx, "user@example.com")
    if err != nil {
        log.Fatal("Verification failed:", err)
    }

    fmt.Println("Email:", result.Email)
    fmt.Println("Status:", result.Status)
    fmt.Println("Score:", result.Score)
    fmt.Println("Disposable:", result.Disposable)
    fmt.Println("RoleAccount:", result.RoleAccount)
    fmt.Println("MX Found:", result.MXFound)
}

Batch Email Verification

package main

import (
    "context"
    "fmt"
    "log"
    "time"

    ev "github.com/ecomtechbd/ev-go"
)

func main() {
    client := ev.NewClient("YOUR_API_KEY")
    ctx := context.Background()

    emails := []string{
        "alice@example.com", "bob@company.org", "test@temp-mail.io",
    }

    // Submit batch job
    job, err := client.VerifyBatch(ctx, emails)
    if err != nil {
        log.Fatal("Batch submission failed:", err)
    }
    fmt.Println("Job ID:", job.ID)

    // Wait for completion
    results, err := client.WaitForBatch(ctx, job.ID,
        ev.WithPollInterval(5*time.Second),
        ev.WithBatchTimeout(10*time.Minute),
    )
    if err != nil {
        log.Fatal("Batch failed:", err)
    }

    for _, r := range results {
        fmt.Printf("%s: %s (score: %d)\n", r.Email, r.Status, r.Score)
    }
}

Check Previous Result with Context Timeout

package main

import (
    "context"
    "fmt"
    "log"
    "time"

    ev "github.com/ecomtechbd/ev-go"
)

func main() {
    client := ev.NewClient("YOUR_API_KEY")

    // Set a 10-second deadline for the entire operation
    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
    defer cancel()

    // Retrieve cached result without using credits
    result, err := client.GetResult(ctx, "user@example.com")
    if err != nil {
        if ev.IsNotFound(err) {
            fmt.Println("No cached result, running fresh verification...")
            result, err = client.Verify(ctx, "user@example.com")
            if err != nil {
                log.Fatal(err)
            }
        } else {
            log.Fatal(err)
        }
    }

    fmt.Printf("Status: %s, Score: %d\n", result.Status, result.Score)
}

Error Handling

The Go SDK follows idiomatic Go error handling by returning errors as the second return value from all methods. Specific error types can be checked using the errors.Is() and errors.As() functions. The SDK defines sentinel errors including ev.ErrAuthentication, ev.ErrRateLimit, ev.ErrValidation, and ev.ErrNetwork. The RateLimitError type provides a RetryAfter field of type time.Duration indicating how long to wait before retrying.

The SDK automatically retries transient errors with exponential backoff, including 429 rate limit responses and 5xx server errors. Configure retry behavior with ev.WithMaxRetries() and ev.WithRetryDelay() options. Context cancellation is respected at all stages, so a cancelled context immediately stops retries. For batch operations, per-email errors are captured in each result's Error field rather than failing the entire batch. Use client.RateLimitRemaining() to check your remaining quota. Wrap the error check in a helper function for cleaner code in handlers that verify many emails.

package main

import (
    "context"
    "errors"
    "fmt"
    "log"
    "time"

    ev "github.com/ecomtechbd/ev-go"
)

func main() {
    client := ev.NewClient("YOUR_API_KEY", ev.WithMaxRetries(3))
    ctx := context.Background()

    result, err := client.Verify(ctx, "user@example.com")
    if err != nil {
        var rateLimitErr *ev.RateLimitError
        if errors.As(err, &rateLimitErr) {
            fmt.Printf("Rate limited. Retry after %v\n", rateLimitErr.RetryAfter)
            time.Sleep(rateLimitErr.RetryAfter)
        } else if errors.Is(err, ev.ErrAuthentication) {
            log.Fatal("Invalid API key. Check EV_API_KEY.")
        } else if errors.Is(err, ev.ErrValidation) {
            fmt.Println("Invalid email format:", err)
        } else {
            log.Fatal("Verification failed:", err)
        }
        return
    }

    fmt.Printf("Status: %s, Score: %d\n", result.Status, result.Score)
}

Frequently Asked Questions

Install with go get github.com/ecomtechbd/ev-go. The SDK requires Go 1.18 or later and has zero external dependencies — it uses only the Go standard library. Import the package and create a client with your API key to get started.

Yes, all SDK methods accept a context.Context parameter for timeout control and cancellation. Use context.WithTimeout for request-level timeouts or context.WithCancel for manual cancellation. The SDK respects context cancellation at the HTTP transport level.

Yes, pass a custom *http.Client via the WithHTTPClient option when creating the client. This allows you to configure custom timeouts, transport settings, proxy configuration, and TLS settings. The default client uses sensible timeouts and connection pooling.

Start Verifying Emails Today

100 daily free verifications. No credit card required. Full API access on all plans. Visit our email verifier to get started.

Try our free email verifier — verify any email instantly, no signup required. Need bulk verification? Upload your list and clean thousands of emails in minutes.

Developers: integrate email verification into your app with our RESTful API — SDKs for 7 languages.

Free tools: SPF checker · DKIM checker · SMTP tester