Skip to content

apiverve/email-validator-node-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Validator API | APIVerve API Tutorial

License: MIT Node.js Express APIVerve | Email Validator

A simple Node.js/Express API service that validates email addresses. Check if emails are real, deliverable, and catch typos before they become bounces.

Screenshot


Get Your Free API Key

This tutorial requires an APIVerve API key. Sign up free - no credit card required.


Features

  • Validate any email address in real-time
  • Check MX records and SMTP connectivity
  • Detect free vs. company email addresses
  • Catch common typos (e.g., gmial.com → gmail.com)
  • Simple REST API with JSON responses
  • Includes a web UI for testing
  • Production-ready error handling

Quick Start

  1. Clone this repository

    git clone https://github.com/apiverve/email-validator-node-tutorial.git
    cd email-validator-node-tutorial
  2. Install dependencies

    npm install
  3. Add your API key

    Open src/config.js and replace the placeholder with your API key:

    API_KEY: 'your-api-key-here'
  4. Start the server

    npm start
  5. Test it out

    Open http://localhost:3000 in your browser, or use curl:

    curl -X POST http://localhost:3000/validate \
         -H "Content-Type: application/json" \
         -d '{"email": "[email protected]"}'

Project Structure

email-validator-node-tutorial/
├── src/
│   ├── routes/
│   │   ├── validate.js  # Email validation endpoint
│   │   └── health.js    # Health check endpoint
│   ├── config.js        # API key and settings
│   └── index.js         # Express app setup
├── public/
│   └── index.html       # Web UI for testing
├── package.json         # Dependencies
├── screenshot.jpg       # Preview image
├── LICENSE              # MIT license
├── .gitignore           # Git ignore rules
└── README.md            # This file

API Reference

POST /validate

Validates an email address and returns detailed information.

Request Body:

{
  "email": "[email protected]"
}

Response (Valid Email):

{
  "success": true,
  "email": "[email protected]",
  "isValid": true,
  "details": {
    "domain": "gmail.com",
    "username": "test",
    "isFreeEmail": true,
    "isCompanyEmail": false,
    "mxValid": true,
    "smtpValid": true,
    "hasTypo": false
  }
}

Response (Invalid Email):

{
  "success": true,
  "email": "[email protected]",
  "isValid": false,
  "details": {
    "domain": "notarealdomain.xyz",
    "username": "bad",
    "isFreeEmail": false,
    "isCompanyEmail": false,
    "mxValid": false,
    "smtpValid": false,
    "hasTypo": false
  }
}

GET /health

Health check endpoint for monitoring.

{
  "status": "ok",
  "timestamp": "2024-01-15T10:30:00.000Z"
}

Use Cases

Email validation is essential for:

  • User Registration - Prevent fake signups and reduce bounces
  • Lead Generation - Verify leads before adding to your CRM
  • Email Marketing - Clean your lists to improve deliverability
  • Contact Forms - Catch typos before users submit
  • E-commerce - Ensure order confirmations reach customers
  • B2B Sales - Verify business emails for outreach

Validation Checks

The API performs multiple validation checks:

Check Description
Format Valid email syntax (regex)
MX Record Domain has mail servers configured
SMTP Mail server accepts connections
Typo Detection Common domain misspellings
Disposable Temporary/throwaway email services
Free vs Company Gmail vs corporate domains

Customization Ideas

  • Add rate limiting with express-rate-limit
  • Store validation results in a database
  • Add batch validation for multiple emails
  • Integrate with your signup flow
  • Add webhook notifications for invalid emails

Related APIs

Explore more APIs at APIVerve:

License

MIT - see LICENSE

Links

Releases

No releases published

Packages

No packages published