A simple Node.js/Express API service that validates email addresses. Check if emails are real, deliverable, and catch typos before they become bounces.
This tutorial requires an APIVerve API key. Sign up free - no credit card required.
- 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
-
Clone this repository
git clone https://github.com/apiverve/email-validator-node-tutorial.git cd email-validator-node-tutorial -
Install dependencies
npm install
-
Add your API key
Open
src/config.jsand replace the placeholder with your API key:API_KEY: 'your-api-key-here' -
Start the server
npm start
-
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]"}'
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
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
}
}Health check endpoint for monitoring.
{
"status": "ok",
"timestamp": "2024-01-15T10:30:00.000Z"
}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
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 |
- 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
Explore more APIs at APIVerve:
- Email Disposable Checker - Detect temporary email addresses
- Phone Validator - Validate phone numbers
- DNS Lookup - Query DNS records
MIT - see LICENSE
- Get API Key - Sign up free
- APIVerve Marketplace - Browse 300+ APIs
- Email Validator API - API details
