Deploy Your Own Email Validator | Unlimited Email Validator [Email Verifier for Free] AfterShip OSS

Raunit Verma - in Projects
Views: 20

Validate your email lists effortlessly with our unlimited email validator. Deploy your own email verifier for free and enhance your email marketing strategy today. Ensure your emails reach the right inboxes with our free, unlimited email validator. Deploy your own email verifier and boost your marketing effectiveness now. Optimize your email campaigns with our free email validator. Deploy your own unlimited email verifier and improve deliverability with ease. Start validating today!

Why Email Verification Matters

Sending emails to non-existent addresses can tank your sender reputation, increasing the chances of your emails being flagged as spam. Sure, you could send an email and wait for a bounce, but that’s a reactive approach that doesn’t help your reputation in the long run.

The Cost of Paid Services vs. a Free Alternative

There are plenty of email verification services out there, some offering free tiers for small-scale use. But for bulk verification? The costs add up fast. That’s where AfterShip’s open-source emailverifier library, written in GoLang, comes into play. It’s free, self-hosted, and packed with features to validate emails effectively.

How It Works

The video walks you through setting up a simple Go server with an /email-validator endpoint. You pass an email address as a query parameter, and the server uses the emailverifier library to check its validity, returning the result in JSON. Here’s what it can do:

  • Domain and MX Record Checks: Verify if the email’s domain exists and has an MX record—works even on your local machine.
  • SMTP Checks: Confirm if the inbox actually exists. This requires deploying the app on a cloud server (more on that below), as local ISPs often block SMTP requests on port 25. The video demos this on a Hostinger VPS, showing details like deliverability and catch-all status.
  • Temporary Email Detection: Spot disposable email addresses to avoid wasting resources.

Local vs. Cloud Deployment

The tutorial shows how to test the verifier locally using Postman, displaying responses for valid, invalid, and temporary emails. Locally, you’re limited to domain checks—SMTP checks time out due to ISP restrictions. For full functionality, you’ll need to deploy it on a cloud provider like Hostinger, Hetzner, or Scaleway. The video confirms a successful deployment on Hostinger, unlocking SMTP verification.

A handy Dockerfile is included, making cloud deployment a breeze with a single command. The video also warns about checking if your provider allows port 25 traffic—crucial for SMTP checks.

Cost-Effective Bulk Verification

Why pay for pricey verification services when you can host your own? The video compares costs, showing how this self-hosted solution can handle bulk email verification at a fraction of the price. It’s a game-changer for businesses or anyone managing large email lists.

Watch the below video to learn step by step.
Below is the main.go file. Start a go project and copy paste the code in main.go and run the server. Watch the video to know more.
package main

import (
	"encoding/json"
	"fmt"
	emailverifier "github.com/AfterShip/email-verifier"
	"github.com/gorilla/mux"
	"log"
	"net/http"
	"time"
)

var (
	verifier = emailverifier.NewVerifier().
		EnableSMTPCheck().
		ConnectTimeout(60 * time.Second).
		OperationTimeout(90 * time.Second)
)

type EmailResponse struct {
	ValidationResult *emailverifier.Result `json:"validation_result"`
	Reachable        string                `json:"reachable_status"`
	Error            string                `json:"error,omitempty"`
}

func validateEmailHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json")

	email := r.URL.Query().Get("email")
	if email == "" {
		w.WriteHeader(http.StatusBadRequest)
		_ = json.NewEncoder(w).Encode(map[string]string{
			"error": "Email parameter is required",
		})
		return
	}

	response := EmailResponse{}
	log.Printf("Verifying email: %s", email)

	ret, err := verifier.Verify(email)
	if err != nil {
		log.Printf("Verification error: %v", err)
		response.Error = fmt.Sprintf("Verify email address failed: %s", err)
		w.WriteHeader(http.StatusOK)
		_ = json.NewEncoder(w).Encode(response)
		return
	}

	if !ret.Syntax.Valid {
		log.Printf("Invalid syntax for email: %s", email)
		response.Error = "Email address syntax is invalid"
		w.WriteHeader(http.StatusOK)
		_ = json.NewEncoder(w).Encode(response)
		return
	}

	response.ValidationResult = ret
	response.Reachable = ret.Reachable
	log.Printf("Verification result for %s: reachable=%s", email, ret.Reachable)

	w.WriteHeader(http.StatusOK)
	_ = json.NewEncoder(w).Encode(response)
}

func main() {
	r := mux.NewRouter()
	r.HandleFunc("/email-validator", validateEmailHandler).Methods("GET")
	r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		_, _ = w.Write([]byte("Email Validator API is running. Use /email-validator?email=example@example.com"))
	})

	log.Println("Server starting on port 8080...")
	log.Fatal(http.ListenAndServe(":8080", r))
}
FROM golang:1.23.4-alpine

WORKDIR /app

RUN apk add --no-cache git

COPY . .

RUN go get github.com/AfterShip/email-verifier
RUN go get github.com/gorilla/mux
RUN go mod tidy
RUN go mod vendor

RUN go build -o email-validator

EXPOSE 8080

CMD ["./email-validator"]

Above is the Dockerfile and main.go file. Watch the video and just run the file and deploy it on your own server to get started for free.

TagsDeploy Your Own Email ValidatorUnlimited Email ValidatorAfterShip OSSEmail Verifier for Free
Raunit Verma-picture
Raunit Verma

Technical Writer at CodingKaro

Share this on
CodingKaro Poster
CodingKaro
4.7

3K+ Downloads

One of its unique features is an automated coding contest reminder, which sets alarms for upcoming coding contests on popular platforms like CodeChef, CodeForces, and LeetCode, without the need for user input. This feature ensures that users never miss a coding contest and can stay updated with the latest coding challenges.

Download CodingKaro
Other Blogs in Projects