DEV Community

Xiao Thomas
Xiao Thomas

Posted on

How to Verify Email Addresses in Node.js (API Guide)

Bad emails silently destroy your sender reputation. In this guide I'll show how to validate emails in Node.js — both a quick syntax check and a real provider-level verification via API.

Basic syntax check (no API needed)

function isValidEmail(email) {
return /^[^\s@]+@[^\s@]+.[^\s@]+$/.test(email);
}

This catches obvious typos but won't tell you if the mailbox actually exists.

Real verification via API

For accurate results you need to check against the actual provider. Here's how to integrate the CheckMail1 (https://checkmail1.com/) API:

const axios = require('axios');

async function verifyEmail(email) {
const res = await axios.get('https://checkmail1.com/api/verify', {
params: { email },
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
return res.data;
}

// Example usage
verifyEmail('user@gmail.com').then(result => {
console.log(result);
// { valid: true, score: 95, provider: 'gmail', method: 'api' }
});

Bulk verification for existing lists

const emails = ['a@gmail.com', 'b@yahoo.com', 'c@outlook.com'];

const results = await Promise.all(
emails.map(email => verifyEmail(email))
);

const valid = results.filter(r => r.valid && r.score > 70);
console.log(${valid.length}/${emails.length} emails are valid);

What the API checks

• Syntax and domain validity
• MX record existence
• Mailbox existence (direct provider API, not SMTP guessing)
• Disposable/temporary email detection
• Spam trap detection

Why not just SMTP?

Gmail, Yahoo and Outlook block SMTP probing. A provider-level API gives accurate results for these major mailboxes where SMTP always returns unknown.

You get 100 free verifications at checkmail1.com (https://checkmail1.com/) — enough to test on a real list before committing.

Top comments (0)