Tutorial: Block Disposable Emails at Signup

Integrate Emailyze into your signup flow to block or flag disposable email addresses at registration. This tutorial walks you through the steps with code examples in Node.js and Python.


Overview

By the end of this tutorial, you'll have a signup flow that:

1. Accepts an email from the user 2. Calls the Emailyze API to check if it's disposable 3. Blocks or allows based on your policy (e.g. block if is_disposable, or use a risk_score threshold) 4. Handles edge cases like masked emails and API failures


Prerequisites


Step 1: Call the API

Before creating the user account, call the Emailyze single-check endpoint:

GET https://api.emailyze.xyz/v1/check/[email protected]

Include your API key in the request:

Authorization: Bearer YOUR_API_KEY

Or:

X-API-Key: YOUR_API_KEY

Node.js (Express):

const axios = require('axios');

async function checkEmail(email) {
  const response = await axios.get(
    `https://api.emailyze.xyz/v1/check/`,
    {
      params: { email },
      headers: {
        'Authorization': `Bearer ${process.env.EMAILYZE_API_KEY}`,
      },
    }
  );
  return response.data;
}

Python (Flask/FastAPI):

import os
import requests

def check_email(email: str) -> dict:
    response = requests.get(
        "https://api.emailyze.xyz/v1/check/",
        params={"email": email},
        headers={"Authorization": f"Bearer {os.environ['EMAILYZE_API_KEY']}"},
    )
    response.raise_for_status()
    return response.json()

Step 2: Parse the Response

The API returns JSON with these key fields:

Example response:

{
  "email": "[email protected]",
  "is_disposable": true,
  "risk_score": 95,
  "provider_type": "disposable",
  "domain": "tempmail.com"
}

Step 3: Block or Allow Logic

Option A: Block if disposable

const result = await checkEmail(email);
if (result.is_disposable) {
  return res.status(400).json({ error: "Disposable email addresses are not allowed." });
}
// Proceed with signup

Option B: Use risk score threshold

result = check_email(email)
if result["risk_score"] >= 80:
    raise HTTPException(400, "This email appears to be temporary. Please use a permanent address.")
# Proceed with signup

Option C: Allow masked, block disposable

Masked emails (Apple Hide My Email, Firefox Relay) may be legitimate. Allow them if your product values user privacy:

if (result.is_disposable && result.provider_type !== "masked") {
  return res.status(400).json({ error: "Disposable emails are not allowed." });
}

Step 4: Masked Email Handling

Masked emails forward to a real inbox. Some businesses allow them; others flag or block. Decide based on your use case:


Full Code Example

Node.js (Express) — complete signup handler:

app.post('/signup', async (req, res) => {
  const { email, password } = req.body;
  if (!email || !password) {
    return res.status(400).json({ error: "Email and password required." });
  }

  try {
    const check = await checkEmail(email);
    if (check.is_disposable && check.provider_type !== "masked") {
      return res.status(400).json({ error: "Disposable email addresses are not allowed." });
    }
    if (check.risk_score >= 90) {
      return res.status(400).json({ error: "This email appears high-risk. Please use a different address." });
    }

    // Create user, send verification, etc.
    // await createUser(email, password);
    res.json({ success: true });
  } catch (err) {
    // See Edge Cases below
    if (err.response?.status === 429) {
      return res.status(503).json({ error: "Too many requests. Please try again later." });
    }
    // Fail open or closed — your choice
    console.error("Emailyze error:", err);
    res.status(500).json({ error: "Unable to verify email. Please try again." });
  }
});

Edge Cases

API down or timeout

Rate limits (429)

Invalid email format

Testing


Signals and Risk Score

Emailyze combines multiple signals to produce is_disposable and risk_score:

The risk score aggregates these. A domain on the disposable list might score 95+; an unknown domain with catch-all and no MX might score 70–85. Use thresholds that match your tolerance: strict (block 70+) vs. lenient (block 90+).


Alternative: Serverless / Edge

If your signup runs on serverless (AWS Lambda, Vercel, etc.) or edge (Cloudflare Workers), the same logic applies. Use your runtime's HTTP client (fetch, axios, etc.) and keep the API key in environment variables. Consider connection pooling and timeouts—Emailyze typically responds in 50–200ms. For high-traffic signups, add client-side caching of recent checks (e.g. Redis, 5-minute TTL) to avoid redundant API calls when users retry with the same email. Cache key: normalized email (lowercase, trimmed). Cache value: the full API response. On cache hit, skip the API call and use the cached result. This reduces latency and API usage for repeated attempts.


See Also