Skip to content
send.io
All posts

Verification email templates: examples and HTML templates

Verification email templates with HTML examples, React components, and secure token generation logic for Node.js and Python. You get copy-paste HTML, token lifecycle code with hashing and single-use enforcement, and send.io integration snippets that work in production.

On this page
TL;DR: A secure verification flow needs three things: a cryptographically random token, a hashed copy stored in your database with an expiry timestamp, and single-use enforcement at redemption. The HTML template is the easy part: a single-column layout with inline CSS renders reliably across Gmail, Outlook, and Apple Mail. Below are copy-paste templates in raw HTML and React Email, the full token lifecycle logic, and Node.js and Python send snippets using the send.io REST API.

A verification link that accepts a replayed token is a security hole, however well the email renders. This guide treats the template as the visible layer of a token lifecycle, and walks through generation, hashing, storage, link construction, single-use enforcement, expiry handling, and retry logic. The token and database logic (random generation, SHA-256 hashing, the used_at conditional update) works with any web framework and any SQL database, while the send snippets target the send.io REST API so you can test the full flow by sending a test email to an address you control before wiring it into production.

HTML templates for account verification emails

The template is the visible layer of the verification flow. This section covers a single-column HTML template, four React Email components for common verification patterns, and the plain-text fallback every send should include.

Customizable verification email structure

A single-column layout is the most reliable way to build a mobile-friendly email that renders consistently across clients. Table-based layouts and inline CSS are widely supported across major email clients, including Gmail, Outlook for Windows, and Apple Mail, and typically render without structural breakage, according to the per-client support data on Can I Email. Exact rendering still varies by client and version, so test each template in the clients your audience uses. Inline CSS applied directly to HTML elements is the most reliable styling method across these clients, because embedded <style> tags are not supported uniformly: Apple Mail supports them, while Outlook for Windows and some Gmail views apply them only partially or not at all.

Here is a single-column verification email template with placeholders for the token URL, expiry window, and support contact:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="margin:0; padding:0; background-color:#f4f4f5;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0"
style="background-color:#f4f4f5;">
<tr>
<td align="center" style="padding: 40px 16px;">
<table role="presentation" width="480" cellpadding="0" cellspacing="0"
style="background-color:#ffffff; border-radius:8px;">
<tr>
<td style="padding: 32px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
<h1 style="margin:0 0 16px; font-size:20px; color:#111827;">
Verify your email address
</h1>
<p style="margin:0 0 24px; font-size:15px; line-height:1.6; color:#374151;">
Click the button below to confirm your email address.
This link expires in {{expiry_hours}} hours.
</p>
<a href="{{verification_url}}"
style="display:inline-block; padding:12px 24px; background-color:#2563eb;
color:#ffffff; font-size:15px; font-weight:600;
text-decoration:none; border-radius:6px;">
Verify email
</a>
<p style="margin:24px 0 0; font-size:13px; line-height:1.6; color:#6b7280;">
If the button doesn't work, paste this URL into your browser:<br>
<span style="word-break:break-all; color:#2563eb;">{{verification_url}}</span>
</p>
<p style="margin:24px 0 0; font-size:13px; color:#6b7280;">
If you didn't create an account, you can ignore this email
or contact <a href="mailto:{{support_email}}" style="color:#2563eb;">support</a>.
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

Four details in this template matter for verification. The outer table at width="100%" centers a 480-pixel inner table, and every style is inline. Both tables use role="presentation" so screen readers don't announce them as data tables. The plain-URL line below the button gives a working path in clients that strip button styling. {{verification_url}} appears twice and must resolve to the same value in both places. The table below compares how the three clients handle the features this layout relies on.

Feature

Gmail

Outlook (Win)

Apple Mail

Inline CSS

Supported

Supported

Supported

Media queries

Limited

Not supported

Full support

Table layout

Supported

Supported

Supported

Single-column

Reliable

Reliable

Reliable

React Email verification components

React Email compiles components to email-safe HTML. The four examples below are illustrative code for common verification patterns, not a published component package: a verification button, a 6-digit OTP display, a magic link, and a plain-text fallback generator. The first three are React Email components, and the fourth is a plain TypeScript function. Adapt each to your own design system and test it in your target email clients before production use.

// 1. Verification button
import { Button, Section, Text } from '@react-email/components';

export function VerificationButton({ url, expiryHours }: {
url: string;
expiryHours: number;
}) {
return (
<Section style={{ padding: '16px 0' }}>
<Text style={{ fontSize: '15px', color: '#374151' }}>
Click below to verify your email. This link expires in {expiryHours} hours.
</Text>
<Button
href={url}
style={{
backgroundColor: '#2563eb',
color: '#ffffff',
padding: '12px 24px',
borderRadius: '6px',
fontSize: '15px',
fontWeight: 600,
textDecoration: 'none',
}}
>
Verify email
</Button>
</Section>
);
}

// 2. Six-digit OTP display
import { Section, Text } from '@react-email/components';

export function OtpDisplay({ code, expiryMinutes }: {
code: string;
expiryMinutes: number;
}) {
return (
<Section style={{ textAlign: 'center', padding: '24px 0' }}>
<Text style={{ fontSize: '13px', color: '#6b7280' }}>
Enter this code to verify your email. It expires in {expiryMinutes} minutes.
</Text>
<Text style={{
fontSize: '32px',
fontWeight: 700,
letterSpacing: '8px',
fontFamily: 'monospace',
color: '#111827',
margin: '8px 0',
}}>
{code}
</Text>
</Section>
);
}

// 3. Magic link (styled as a text link)
import { Link, Section, Text } from '@react-email/components';

export function MagicLink({ url }: { url: string }) {
return (
<Section style={{ padding: '16px 0' }}>
<Text style={{ fontSize: '15px', color: '#374151' }}>
Click this link to sign in. It can only be used once.
</Text>
<Link href={url} style={{ color: '#2563eb', fontSize: '15px' }}>
Sign in to your account
</Link>
</Section>
);
}

// 4. Plain-text fallback generator
export function generatePlainText(url: string, expiryHours: number): string {
return [
'Verify your email address',
'',
`Open this link in your browser to verify your email:`,
url,
'',
`This link expires in ${expiryHours} hours and can only be used once.`,
'',
`If you didn't create an account, ignore this email.`,
].join('\n');
}

For teams already sending other transactional messages, the transactional email templates guide covers the same React Email integration pattern applied to receipts, alerts, and onboarding sequences.

Fallback logic for text emails

Every verification email should include a plain-text MIME part with the same full verification URL as the HTML version. Some clients render text by default (accessibility tools, plain-text readers, corporate security environments), so a different URL in the text part means two separate links to keep in sync. If the HTML and text URLs drift apart (a typo, a stale value, the wrong domain), one link breaks silently while the other keeps working. The generatePlainText function above produces a text string you can pass to the text field in your send call.

Structuring secure verification link payloads

The link in the email carries the credential, so the token behind it determines how secure the whole flow is. The next three subsections cover generating the token, formatting the verification URL, and storing token metadata in your database.

Generate cryptographically secure tokens

Use crypto.randomBytes(32).toString('base64url') in Node.js or secrets.token_urlsafe(32) in Python. Both produce a URL-safe string with 256 bits of entropy. The base64url encoding avoids characters like + and / that break unescaped in a query parameter, as noted in RunXBuild's Node.js random string guide.

The Python secrets module documentation confirms that 32 bytes of randomness is sufficient for the typical security use case. The OWASP Session Management Cheat Sheet requires session identifiers to come from a cryptographically secure pseudorandom number generator (CSPRNG) and to carry at least 64 bits of entropy to prevent brute-force guessing attacks, and the 256 bits produced by 32 random bytes clears that minimum by a wide margin.

Do not use Math.random() or random.random(). Neither is cryptographically secure. UUID v4 produces only 122 bits of entropy and was not designed for security tokens.

// Node.js
import crypto from 'node:crypto';
const rawToken = crypto.randomBytes(32).toString('base64url');

# Python
import secrets
raw_token = secrets.token_urlsafe(32)

Formatting your verification URL

Construct the URL with the raw token as a query parameter. This example also includes the user's email address, so your verification endpoint can confirm the token belongs to the expected account before consuming it. The tradeoff of putting the email in the URL is covered below the example:

https://<your-app-domain>/verify?token=<raw_token>&email=<user_email>

Do not put the token in a URL fragment (#token=...). Fragments are never sent to the server, so your backend cannot read them without client-side JavaScript extracting the value and making a separate request. That adds a failure mode without improving security, because the token still travels over HTTPS in the query string.

The email parameter has a privacy cost. A raw email address in a query string can end up in server access logs, browser history, and Referer headers, the same leakage paths that make the token sensitive. The token_hash column is unique, so the token alone identifies the row. If you don't need the email as a second check, drop it from the URL and remove the email = ? conditions from the queries and code in this article. If you keep it, exclude query strings from access logs and send a Referrer-Policy: no-referrer header on the verification page.

Database schema for token metadata

Store the SHA-256 hash of the token, never the raw value. A database leak that exposes token hashes does not give an attacker usable verification links, because the hash is one-way. This pattern mirrors password storage but is simpler: the token has enough entropy that a fast hash like SHA-256 is sufficient, unlike passwords where you need bcrypt or Argon2. The schema and lookup queries in this article use MySQL 8 syntax. On PostgreSQL, use BIGSERIAL for the id column, TIMESTAMPTZ for timestamps, and encode(digest(token, 'sha256'), 'hex') from the pgcrypto extension in place of UNHEX(SHA2(?, 256)). On SQLite, compute the SHA-256 hash in application code and store it in a TEXT column.

CREATE TABLE email_verifications (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT NOT NULL,
token_hash CHAR(64) NOT NULL, -- SHA-256 hex digest
email VARCHAR(255) NOT NULL,
created_at DATETIME NOT NULL DEFAULT NOW(),
expires_at DATETIME NOT NULL,
used_at DATETIME NULL,
UNIQUE KEY idx_token_hash (token_hash),
INDEX idx_user_id (user_id)
);

The used_at column enforces single-use redemption. The lookup query pattern:

SELECT id, user_id, expires_at, used_at
FROM email_verifications
WHERE token_hash = UNHEX(SHA2(?, 256))
AND email = ?;

If the row exists, used_at IS NULL, and expires_at > NOW(), the token is valid.

Enforcing single-use token verification

A token that can be redeemed twice is a replay vulnerability. This section covers how long tokens should stay valid, how to consume a token atomically on first use, and how to handle tokens that expire before the user clicks.

Define verification link TTL values

Different flows need different expiry windows. Account verification links can be generous because the user might not check email immediately. Password reset and OTP codes need shorter windows because they guard higher-stakes actions.

Use case

Recommended TTL

Rationale

Account verification

24 hours

User may not check email immediately after signup

Password reset

10 minutes

Higher-stakes action. NIST SP 800-63B §5.1.3.2 sets a 10-minute expiry for out-of-band authentication secrets

OTP code

5 minutes

Short-lived by design. User is actively waiting

The 10-minute ceiling for out-of-band tokens follows NIST SP 800-63B §5.1.3.2, which covers authentication secrets delivered out of band, such as codes sent by email or SMS. Account verification allows a longer window because users may not check email immediately, but longer TTLs increase the window during which a leaked token remains valid.

Invalidate tokens after first use

Set used_at on successful verification, and use a conditional UPDATE that fails if the token has already been consumed:

UPDATE email_verifications
SET used_at = NOW()
WHERE token_hash = UNHEX(SHA2(?, 256))
AND email = ?
AND used_at IS NULL
AND expires_at > NOW();

Check the affected row count. If the update affects zero rows, the token is either invalid, expired, or already used. Return the appropriate error. This atomic update prevents the race condition where two concurrent requests both read used_at IS NULL before either writes, which would allow the same token to verify two sessions.

In your application code:

const result = await db.query(
`UPDATE email_verifications
SET used_at = NOW()
WHERE token_hash = UNHEX(SHA2(?, 256))
AND email = ?
AND used_at IS NULL
AND expires_at > NOW()`,
[rawToken, email]
);

if (result.affectedRows === 0) {
// Token invalid, expired, or already used
return res.status(401).json({ error: 'token_invalid' });
}

// Token consumed successfully. Mark the user as verified.
await db.query(
'UPDATE users SET email_verified = 1 WHERE id = ?',
[userId]
);

Handling expired verification tokens

Return a specific error code for expired tokens so the client can show a targeted message and offer a resend button:

{
"error": "token_expired",
"message": "This verification link has expired. Request a new one."
}

The resend flow follows a fixed sequence: invalidate the old token (delete the row or set used_at), generate a new token with a fresh expiry, store the new token hash, send the new verification email, and rate-limit the resend endpoint to prevent abuse (the retry handling section implements this with a Redis-backed fixed window). Do not extend the expiry of the existing token. Generating a fresh token ensures any copy of the old link is permanently invalidated.

Email verification template code snippets

The snippets in this section connect the token lifecycle to the send.io REST API. They cover the Node.js and Python send implementations and the error responses your verification endpoint returns, including a complete Express route handler.

Node.js verification email integration

This snippet generates a token, hashes it, stores it, and sends the email via send.io's REST API with an Idempotency-Key header.

import crypto from 'node:crypto';

// Assumed bindings from your application:
// - db: a mysql2 client (the queries in this article use MySQL 8 syntax,
// and the handlers read result.affectedRows, which is mysql2-specific;
// pg exposes rowCount instead)
// - renderVerificationHtml(url, hours): the HTML template from the
// previous section with {{verification_url}}, {{expiry_hours}}, and
// {{support_email}} filled in
// - generatePlainText(url, hours): the plain-text fallback defined above

const SENDIO_API_KEY = process.env.SENDIO_API_KEY;
const API_BASE = process.env.SENDIO_API_URL; // the send.io API base URL

async function sendVerificationEmail(userId, email) {
// 1. Generate the raw token (never stored or logged)
const rawToken = crypto.randomBytes(32).toString('base64url');

// 2. Hash for storage
const tokenHash = crypto.createHash('sha256').update(rawToken).digest('hex');

// 3. Store in database with 24-hour expiry
const expiresAt = new Date(Date.now() + 24 * 60 * 60 * 1000);
await db.query(
`INSERT INTO email_verifications (user_id, token_hash, email, expires_at)
VALUES (?, ?, ?, ?)`,
[userId, tokenHash, email, expiresAt]
);

// 4. Build the verification URL
const appBaseUrl = process.env.APP_BASE_URL; // Your app's public base URL
const verificationUrl = `${appBaseUrl}/verify?token=${rawToken}&email=${encodeURIComponent(email)}`;

// 5. Send via send.io with idempotency key
const idempotencyKey = `verify-${userId}-${tokenHash.slice(0, 16)}`;

const response = await fetch(`${API_BASE}/emails`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${SENDIO_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body: JSON.stringify({
from: 'App <noreply@app.example.com>',
to: [email],
subject: 'Verify your email address',
html: renderVerificationHtml(verificationUrl, 24),
text: generatePlainText(verificationUrl, 24),
}),
});

if (!response.ok) {
const error = await response.json();
throw new Error(`send.io API error: ${response.status} ${JSON.stringify(error)}`);
}

return response.json();
}

The Idempotency-Key ensures that a retried request returns the original result instead of sending a duplicate.

Python email verification implementation

import hashlib
import os
import secrets
from datetime import datetime, timedelta, timezone
from urllib.parse import quote

import requests

# Assumed bindings from your application:
# - db: your database client (psycopg, pymysql, or similar)
# - render_verification_html(url, hours): the HTML template from
# the previous section with its placeholders filled in
# - generate_plain_text(url, hours): a Python port of the plain-text
# fallback generator shown earlier

SENDIO_API_KEY = os.environ['SENDIO_API_KEY']
API_BASE = os.environ['SENDIO_API_URL'] # the send.io API base URL

def send_verification_email(user_id: int, email: str):
# 1. Generate the raw token
raw_token = secrets.token_urlsafe(32)

# 2. Hash for storage
token_hash = hashlib.sha256(raw_token.encode()).hexdigest()

# 3. Store in database with 24-hour expiry
expires_at = datetime.now(timezone.utc) + timedelta(hours=24)
db.execute(
"""INSERT INTO email_verifications
(user_id, token_hash, email, expires_at)
VALUES (%s, %s, %s, %s)""",
(user_id, token_hash, email, expires_at),
)

# 4. Build the verification URL (URL-encode the email, matching
# encodeURIComponent in the Node.js snippet)
app_base_url = os.environ['APP_BASE_URL'] # Your app's public base URL
verification_url = (
f"{app_base_url}/verify"
f"?token={raw_token}&email={quote(email, safe='')}"
)

# 5. Send via send.io with idempotency key
idempotency_key = f"verify-{user_id}-{token_hash[:16]}"

response = requests.post(
f"{API_BASE}/emails",
headers={
"Authorization": f"Bearer {SENDIO_API_KEY}",
"Content-Type": "application/json",
"Idempotency-Key": idempotency_key,
},
json={
"from": "App <noreply@app.example.com>",
"to": [email],
"subject": "Verify your email address",
"html": render_verification_html(verification_url, 24),
"text": generate_plain_text(verification_url, 24),
},
)
response.raise_for_status()
return response.json()

For delivery layer decision criteria, see the SMTP vs API comparison.

Managing verification token errors

Your verification endpoint should return distinct error codes so the frontend can show specific messages.

Error condition

HTTP status

Response body

Token not found

404

{"error": "token_not_found", "message": "Verification token does not exist."}

Token expired

401

{"error": "token_expired", "message": "This link has expired. Request a new one."}

Return 404 for a token that does not match any hash in the database and 401 for a token that exists but fails the expiry or single-use checks (expires_at < NOW() or used_at IS NOT NULL). Each status maps to a different frontend action: 404 shows "invalid link," and 401 shows "request a new link," which keeps the response consistent with the conditional UPDATE above that treats consumed tokens as invalid.

Here is a complete pair of Express route handlers that ties the lookup, the confirmation step, the conditional update, and the two error responses together. The GET route only checks that the token exists and renders a confirm button. The POST route consumes the token:

import crypto from 'node:crypto';
import express from 'express';

const router = express.Router();
router.use(express.urlencoded({ extended: false }));

function tokenNotFound(res) {
return res.status(404).json({
error: 'token_not_found',
message: 'Verification token does not exist.',
});
}

function escapeHtml(value) {
return String(value)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}

// Confirm a row exists for this token hash and email (read-only)
async function findVerification(token, email) {
const tokenHash = crypto.createHash('sha256').update(token).digest('hex');
const rows = await db.query(
`SELECT id, user_id FROM email_verifications
WHERE token_hash = ? AND email = ?`,
[tokenHash, email]
);
return rows.length > 0 ? rows[0] : null;
}

// GET is read-only. Email-security scanners and link previewers that
// pre-fetch the URL only see the confirm page, and the token stays unused.
router.get('/verify', async (req, res) => {
const { token, email } = req.query;
if (!token || !email) {
return tokenNotFound(res);
}

const row = await findVerification(token, email);
if (!row) {
return tokenNotFound(res);
}

return res.status(200).send(`<!DOCTYPE html>
<html>
<body>
<form method="POST" action="/verify">
<input type="hidden" name="token" value="${escapeHtml(token)}">
<input type="hidden" name="email" value="${escapeHtml(email)}">
<button type="submit">Confirm your email address</button>
</form>
</body>
</html>`);
});

// POST consumes the token, and only runs when a person submits the form
router.post('/verify', async (req, res) => {
const { token, email } = req.body;
if (!token || !email) {
return tokenNotFound(res);
}

// 1. Confirm a row exists for this token hash and email
const row = await findVerification(token, email);
if (!row) {
return tokenNotFound(res);
}

const { id: verificationId, user_id: userId } = row;

// 2. Consume the token atomically. Fails if it is expired or already used
const result = await db.query(
`UPDATE email_verifications
SET used_at = NOW()
WHERE id = ?
AND used_at IS NULL
AND expires_at > NOW()`,
[verificationId]
);

if (result.affectedRows === 0) {
return res.status(401).json({
error: 'token_expired',
message: 'This link has expired. Request a new one.',
});
}

// 3. Token consumed. Mark the user as verified
await db.query(
'UPDATE users SET email_verified = 1 WHERE id = ?',
[userId]
);

return res.status(200).json({ verified: true });
});

The SELECT gives you the 404 path, and the conditional UPDATE gives you the 401 path, so each error code in the table above maps to exactly one branch in the handler. The POST route repeats the SELECT because a client can submit it directly without loading the GET page first.

The confirm step has a cost: the user clicks one extra button. It exists because email-security scanners and link previewers routinely pre-fetch URLs in incoming messages with GET requests. If the GET route consumed the token, a scanner could mark the account verified, or burn the single-use token, before the user ever opens the email. Keeping GET free of side effects and consuming the token on POST means only a deliberate form submission completes verification.

Error handling for verification emails

Verification flows fail in predictable places: the message bounces, the send gets retried, an attacker forges a link, or a user triggers repeated resends. The subsections below cover how to handle each failure mode.

Managing bounced verification emails

Subscribe to bounce webhooks from your email provider so your application can react when a verification email fails to deliver. send.io's bounce webhook payload includes the message ID, event type, timestamp, recipient, and a bounce object with a type field (Permanent or Transient), subtype, message, and per-recipient diagnostic code.

An illustrative permanent bounce payload looks like this. Confirm the exact field names against the webhooks section of the API reference before you parse it in production:

{
"message_id": "msg_01HXYZ...",
"event": "bounced",
"timestamp": "2026-10-14T09:32:11Z",
"recipient": "user@example.com",
"bounce": {
"type": "Permanent",
"subtype": "NoSuchUser",
"message": "Mailbox not found",
"diagnostic_code": "550 5.1.1 User unknown"
}
}

The type field drives your handling logic, and the diagnostic_code carries the remote server's raw SMTP response.

When a permanent bounce arrives for a verification email, mark the user's email address as invalid in your database and prompt them to re-enter it on their next login attempt. A transient bounce (full mailbox, temporary server issue) warrants a retry after a delay, not an immediate invalidation. Log the diagnostic code for debugging.

Idempotent verification link logic

The Idempotency-Key header prevents duplicate verification emails when your application retries a send. send.io stores the key for 24 hours and returns the original response for any retry with the same key, whether the caller is a server process or an AI agent.

If you are building OTP-based verification alongside link-based verification, the email OTP implementation guide covers the rate limiting and latency controls specific to code-based flows.

Preventing forged verification links

Hash tokens before storage so a database leak does not expose usable links. Compare hashes in constant time using crypto.timingSafeEqual() in Node.js or hmac.compare_digest() in Python to prevent timing attacks.

Some teams use JWT for verification tokens instead of opaque random tokens. JWTs can be validated without a database lookup but cannot be revoked before expiry without maintaining a blocklist. Opaque tokens stored in a database are simpler to invalidate: set used_at or delete the row.

Handling verification retry requests

Rate-limit the resend endpoint to prevent email bombing, where an attacker triggers repeated verification emails to a victim's address. A simple Redis-backed fixed window works:

# Example policy only. Implementations vary (for example, 3 per hour, 3 per 5 minutes, or 5 per hour),
# and no standard mandates one limit. Tune the limit and window to your own traffic.
Key: "verify_resend:{email}"
Value: request count for the current window
TTL: 3600 seconds (1-hour fixed window)
Limit: 3 requests per hour per email address

import { createClient } from 'redis';

const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();

const RESEND_LIMIT = 3;
const RESEND_WINDOW_SECONDS = 3600;

// Returns true when the resend is allowed, false when the limit is exceeded
async function checkResendRateLimit(email) {
const key = `verify_resend:${email}`;
const count = await redis.incr(key);
if (count === 1) {
// First request in the window, so start the expiry clock
await redis.expire(key, RESEND_WINDOW_SECONDS);
}
return count <= RESEND_LIMIT;
}

When a user requests a resend, increment the counter. If the count exceeds 3, return a 429 status with a Retry-After header. For failed sends that cannot be recovered, push the message to a dead-letter queue for manual review.

Test this verification flow end-to-end by sending a test email to an address you control before wiring it into production. Provision an account at send.io, point the Node.js or Python snippet above at the send.io API base URL, and confirm that token generation, email delivery, bounce webhooks, and idempotency behavior match your application's requirements.

FAQs

How long should verification tokens be valid?

A common baseline is 24 hours for account verification, 10 to 60 minutes for password reset (shorter for higher-risk apps), and 5 minutes or less for OTP codes, tuned to your own risk profile. NIST SP 800-63B §5.1.3.2 sets a 10-minute expiry for out-of-band authentication secrets delivered via email or SMS.

What happens if a user never verifies their email?

Keep the account in an unverified state that allows login and profile setup but blocks actions such as sending messages, publishing content, or making purchases. Delete unverified accounts after 30 days, with a reminder email sent at day 25. Delete expired token rows on a scheduled job to keep the table small.

Should verification links work after password reset?

No. A password reset should invalidate any outstanding email verification tokens for that user. Generate a new verification token after the reset completes, so the user re-verifies with a fresh link tied to the new credential state.

How do you test verification emails in development?

Point your send call at a local mail catcher (Mailpit, MailHog) or send a test email to an address you control. For automated tests, stub the HTTP layer and assert on the request body rather than sending real email, and validate the token lifecycle (generate, hash, store, verify, invalidate) against a test database.

Key terms glossary

Token hash: A one-way SHA-256 digest of the raw verification token, stored in the database to prevent a leak from exposing usable links.

TTL: The duration a verification token remains valid, enforced by comparing expires_at against the current time.

Idempotency key: A client-generated header that deduplicates API requests by returning the original result for retries with the same key.

Single-use token: A verification token that becomes invalid after first redemption, enforced by a conditional UPDATE that sets used_at only if the row is unconsumed.

Dead-letter queue: A holding area for messages that failed processing after all retry attempts, allowing manual review without blocking the primary pipeline.

Webhook payload: The JSON body delivered by an HTTP callback to your endpoint, carrying event data like message ID, recipient, and diagnostic codes.