APIIntegrationEmail VerificationDeveloper GuideTutorial

How to Integrate Email Verification API in Your Application

January 19, 2025
By PureMail Team

Building an app that collects email addresses?

You need email verification — or you'll end up with fake signups, spam, and deliverability issues.

The good news? Adding email verification is simple when you use an API.

Here's how to integrate email verification into your app — with real code examples.

Why Use an Email Verification API?

An email verification API lets you check if an email address is valid before it enters your database.

Benefits:

  • Block fake signups at the source
  • Improve data quality from day one
  • Protect deliverability by never emailing invalid addresses
  • Save money by not storing junk emails

Real-time verification means only real users get through.

What You'll Need

Before integrating, make sure you have:

  1. An API key from PureMail (free to start)
  2. Your application's backend code access
  3. 10 minutes to implement

Let's get started.

Step 1: Get Your API Key

Sign up for PureMail and grab your API key from the dashboard.

Go to Dashboard > API Keys and copy your key.

You'll use this to authenticate your requests.

Step 2: Choose Your Integration Method

There are two main ways to verify emails with an API:

Real-Time Verification – Check emails instantly when users sign up

Bulk Verification – Upload and verify lists of emails at once

For this guide, we'll focus on real-time verification since it's the most common use case.

Step 3: Add Real-Time Verification to Your Signup Form

Here's how to verify emails when users submit a signup form.

Example: Node.js / Express

const express = require('express');
const axios = require('axios');

const app = express();
app.use(express.json());

const PUREMAIL_API_KEY = 'your-api-key-here';

app.post('/signup', async (req, res) => {
  const { email, name } = req.body;

  try {
    // Verify email with PureMail API
    const response = await axios.post(
      'https://puremail.dev/api/v1/verify',
      { email },
      {
        headers: {
          'Authorization': `Bearer ${PUREMAIL_API_KEY}`,
          'Content-Type': 'application/json'
        }
      }
    );

    const { status, reason } = response.data;

    if (status === 'valid') {
      // Email is good - save to database
      await saveUser({ email, name });
      return res.json({ success: true, message: 'Account created!' });
    } else if (status === 'risky') {
      // Optional: allow risky emails but flag them
      await saveUser({ email, name, flagged: true });
      return res.json({ success: true, message: 'Account created (risky email detected)' });
    } else {
      // Email is invalid - reject signup
      return res.status(400).json({
        success: false,
        message: `Invalid email: ${reason}`
      });
    }
  } catch (error) {
    console.error('Email verification failed:', error);
    // Fail open or closed depending on your requirements
    return res.status(500).json({ success: false, message: 'Verification error' });
  }
});

app.listen(3000, () => console.log('Server running on port 3000'));

Example: Python / Flask

from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

PUREMAIL_API_KEY = 'your-api-key-here'

@app.route('/signup', methods=['POST'])
def signup():
    data = request.json
    email = data.get('email')
    name = data.get('name')

    # Verify email with PureMail API
    try:
        response = requests.post(
            'https://puremail.dev/api/v1/verify',
            json={'email': email},
            headers={
                'Authorization': f'Bearer {PUREMAIL_API_KEY}',
                'Content-Type': 'application/json'
            }
        )

        result = response.json()
        status = result.get('status')
        reason = result.get('reason')

        if status == 'valid':
            # Email is good - save to database
            save_user(email, name)
            return jsonify({'success': True, 'message': 'Account created!'})
        elif status == 'risky':
            # Optional: allow risky but flag
            save_user(email, name, flagged=True)
            return jsonify({'success': True, 'message': 'Account created'})
        else:
            # Invalid email - reject
            return jsonify({'success': False, 'message': f'Invalid email: {reason}'}), 400

    except Exception as e:
        print(f'Verification error: {e}')
        return jsonify({'success': False, 'message': 'Verification failed'}), 500

if __name__ == '__main__':
    app.run(port=3000)

Step 4: Handle API Responses

PureMail returns clear results:

valid – Email is safe to use

invalid – Email is fake, mistyped, or doesn't exist

risky – Email might be temporary, catch-all, or inactive

You decide how to handle each status based on your needs.

Step 5: Test Your Integration

Before going live, test with sample emails:

  • Valid: test@gmail.com
  • Invalid: fake@notarealdomain123.com
  • Risky: temp@mailinator.com (disposable email)

Make sure your app rejects invalid emails and handles risky ones properly.

Best Practices

Always verify server-side – Never rely on client-side validation alone

Cache results – Store verification results to avoid redundant API calls

Handle errors gracefully – Decide whether to "fail open" (allow signup) or "fail closed" (block signup) if the API is down

Monitor usage – Track your API credit usage in the PureMail dashboard

Bulk Verification (Bonus)

Need to verify a list of emails at once?

Use the bulk verification endpoint:

const response = await axios.post(
  'https://puremail.dev/api/v1/verify/bulk',
  {
    emails: ['user1@example.com', 'user2@example.com', 'user3@example.com']
  },
  {
    headers: {
      'Authorization': `Bearer ${PUREMAIL_API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

You'll get results for all emails in one request.

The Bottom Line

Integrating email verification is one of the smartest things you can do for your app.

It takes minutes to set up and saves you from fake signups, bad data, and deliverability issues.

Start verifying emails the right way.

👉 Get your free API key and start integrating PureMail today

Ready to clean your email list?

Start verifying your emails today with PureMail. Get 150 free credits when you sign up.

PureMail Logo

© 2025 PureMail. All rights reserved.