Skip to main content
16 min read

Email Verification Codes: What Works Today and What Is Still a Draft, Tested

Email Verification Codes: What Works Today and What Is Still a Draft, Tested

We sent the proposed OTP-Token email header through SMTPfast and Resend, read the raw messages on the receiving side, and then forged the header. In those messages the value arrived unchanged, and DKIM still passed after we changed it, because no DKIM signature on them covered the header. We also ran Chrome's Email Verification API end to end in Chrome 159: it verified an address without sending an email, but only after a browser prompt was accepted. While doing that, we found that the example verification code in Chrome's verifier guide never checks the token's key binding, so it accepts a token that was minted for another site.

This post started from Resend's guide, The Future of Email Verification (24 November 2026), which explains three things Google is working on: Gmail's "Copy code" button, the Email Verification API, and the OTP-Token header. It is a good overview. Here we test the parts we could test, say which part we could not, and build a sign-up flow around the emailed code, which has to stay available to every user.

TL;DR

  • Works today: a plain emailed code with a short expiry, a few attempts, single use and rate limits, checked against your own origin. Put the code alone on its own line, and add autocomplete="one-time-code" to the input.
  • OTP-Token header (draft-goto-otp-token-01, an individual Internet-Draft): Resend's guide says no email client reads it yet. We made 10 sends and 9 were delivered. In the 7 delivered messages that carried the header, the value arrived unchanged (Resend folded two long ones, which the draft allows for), but no DKIM signature included the header, so a forged value still passed DKIM. A message with two copies of the header, which the draft's parser rejects, was delivered by one provider.
  • Email Verification API: an origin trial in Chrome 150 to 160. In Chrome 159 it worked with our own verifier and the mock issuer from Chrome's docs. No token was sent until the browser prompt was accepted.
  • Chrome's verifier snippet: it passes { kb: { expectedNonce, expectedAudience } } to @sd-jwt/core, whose verify() ignores that option in the two versions we tested and skips the key binding check. In a replay harness, a token Chrome minted for our site was accepted by the snippet with another session's nonce and another site's audience. Our verifier rejected it.
  • WebOTP: transport: ["email"] is rejected with a TypeError in Chrome 159. Only SMS exists.
  • Not tested: Gmail's "Copy code" button, and any receiving service other than Amazon SES.

Prerequisites

  • Node.js 22 or newer
  • An email API that accepts custom headers, and a receiving inbox you own where you can read the raw message (we used SMTPfast inbound)
  • For the browser part: Playwright, Xvfb, and a Chromium build between 150 and 160
  • Basic knowledge of DKIM and DMARC

Everything below comes from one repo. The 69 tests run offline in CI; the sends and the browser runs are scripts whose output is saved in results/, and each JSON report is stamped with the commit that produced it.

The three pieces, and their status today

Piece Status (28 Nov 2026) Who reads it today What you can do now
Gmail "Copy code" Live in Gmail, per Resend's guide Gmail Keep the code easy to find
OTP-Token header Individual Internet-Draft, revision 01 No email client yet, per Resend's guide Send it; it costs one header
Email Verification API Chrome origin trial, 150 to 160 desktop, 154 to 160 Android Chrome; Gmail participates as a provider Add a hidden field, verify the token, fall back to a code
WebOTP Supported in Chromium-based browsers for SMS Chrome; desktop Chrome via a signed-in Android phone Nothing for email: there is no email transport

Resend writes that Gmail's code extraction and "Copy code" button "appear to work based on heuristics". We did not find Google documentation of how Gmail detects codes, and we could not test it, so we make no claim about which email layout gets the button.

Part 1: the code that works today

Every newer mechanism is a progressive enhancement over an emailed code. Users of desktop or mobile mail clients, and users who are not signed in to webmail in that browser, still get the code, so it has to be done well. The demo's src/codes.js follows these rules:

export const DEFAULTS = Object.freeze({
  digits: 6,
  ttlMs: 10 * MINUTE, // short expiry
  maxAttempts: 5, // then the code is dead, even if the 6th guess is right
  resendCooldownMs: MINUTE, // one new code per minute per address
  maxSendsPerEmailPerHour: 5,
  maxSendsPerIpPerHour: 20,
});

The store keeps an HMAC of origin + email + code, never the code itself, and deletes the entry on the first successful check. Issuing a new code replaces the old one. The per-IP limit is checked before anything is stored for a new address, so a flood of new addresses from one client does not grow memory.

The part that is easy to skip is the origin. The code is bound to the site that issued it, and the check compares that origin with the Origin header of the request that submits the code:

// server.js: the browser's Origin header says which site submitted the form.
const r = store.verify({ email: s.email, origin: req.headers.origin, code: form.code });

Be clear about what this stops. It stops a page on another site from posting the code to your form from the user's browser, because the browser sets Origin and the page cannot change it. It does not stop a phishing site that asks the user to type the code and then submits it from its own server, because a server can send any Origin header it likes. The OTP-Token draft says the same about origin-bound codes in general: "This doesn't prevent phishing as users can still be tricked into typing the code manually".

The demo server applies the same Origin check to every form post, creates sessions only when it renders the form, validates the email on the server, and has request budgets per client (an IPv4 address or an IPv6 /64), so a cross-site form cannot make it send mail and one client cannot crowd out the others. The tests cover expiry at 10 minutes, the lock after 5 wrong attempts, the right digits from the wrong origin, the cooldown, the per-IP limit and the cross-site post. The input on the code page uses the attributes that browsers already understand:

<input
  id="code"
  name="code"
  type="text"
  inputmode="numeric"
  autocomplete="one-time-code"
  pattern="\d{6}"
  maxlength="6"
  required
/>

The email itself is plain: the code on a line of its own, the origin it works on, the expiry, and a line saying the site will never ask for it by phone or chat.

Your OTP Lab verification code is:

386709

This code works only on https://otp-lab.devops-daily.com and expires in 10 minutes.
OTP Lab will never ask you for this code by phone, chat or email.
If you did not ask for it, you can ignore this email.

For more on second factors in general, the OWASP authentication failures chapter explains why passkeys come first and email codes are a fallback.

Part 2: the OTP-Token header, measured

The draft defines one header that carries the code and the origin it is bound to:

OTP-Token: "123456"; origin="https://example.com"

The value is an HTTP Structured Field (RFC 9651): a String for the code, and an origin parameter that must be a canonical, potentially trustworthy origin. The parsing algorithm in section 3.2 fails if the message has zero or more than one OTP-Token field, and fields inside MIME body parts are ignored. The draft says it "can be considered an email-based implementation of" the origin-bound SMS format, which is the format WebOTP reads.

Disclosure: SMTPfast is our product. We used it and Resend because those are the two email APIs we have accounts on.

Adding the header is one line with any API that accepts custom headers:

Build the value with a Structured Fields serializer rather than string concatenation, so a code with a quote in it cannot break the header. SMTPfast plans an otp option that adds the header for you (no date yet); until then the normal headers field passes it through, as the test below shows.

What we sent

Five variants, each through both providers with the same message and layout, from [email protected] to an SMTPfast inbound address on our own domain. The send script refuses any recipient outside a configured list of our own domains.

Variant What is special
v1-draft-form The draft's example form
v2-long-line A long origin, so the line is over 78 characters
v3-token-param The token=:...: byte sequence from the draft's "Future Work" section
v4-duplicate Two fields, sent as two JSON keys: OTP-Token and otp-token
v5-control-no-header No header, to check that nothing on the path adds one

Tracking was off for the SMTPfast sends. Our Resend domain has open tracking turned on, so Resend added a tracking image to the HTML part; that changes the body, not the headers. Then 02-fetch-received.js downloaded the raw MIME of each message from the receiving API, and 03-check-headers.js compared it with what we sent:

identical=true means the value matched byte for byte after unfolding and trimming whitespace. For the control messages, it only means that no field was added. What this shows:

  • The value survived. All seven messages that carried the header arrived with the value unchanged after unfolding, including the long line and the token parameter. No hop added a header to either control message.
  • Resend folded long lines. The two Resend headers over 78 characters (v2 and v3) arrived folded after the ;, for example Otp-Token: "075576"; followed by a continuation line origin="https://a-long-subdomain-...". SMTPfast sent the same lines unfolded. Both are valid mail; it is why section 3.2 of the draft unfolds the field before parsing it as a Structured Field. A reader that skips that step would reject the folded copies.
  • The name did not survive exactly. Resend delivered it as Otp-Token in all three messages. Our parser matches names without regard to case; a reader that matched only the exact string OTP-Token would miss them.
  • Two fields: one delivered, one missing. SMTPfast delivered both OTP-Token and otp-token, and the draft's parser rejects such a message at step 1. Resend accepted the same request with HTTP 200, but the message had not arrived 10 minutes later. Our key can only send, so we cannot see why. Either way, a sender should refuse to add the header twice.
Note

These are lab results with one message per variant and provider. Both providers sent these messages through Amazon SES, and our receiving inbox is also on Amazon SES, so "arrived unchanged" is shown for that path only. Gmail, Outlook.com and other receiving services may treat unknown headers differently; we did not test them.

DKIM did not cover the header

A DKIM signature only protects the headers listed in its h= tag. The received messages carried these lists:

Signature Signed headers
devops-daily.com, sent by SMTPfast from:to:subject:date:message-id:mime-version:content-type
devops-daily.com, sent by Resend from:to:subject:message-id:date:mime-version:content-type
amazonses.com, both the same plus feedback-id

OTP-Token is not in any of them. So the break script, 04-tamper-otp-token.js, rewrites the header to a different code and an attacker's origin, then checks DKIM again. As a control it also edits the Subject, which is signed. One message from each provider:

All seven forged headers still passed DKIM, and all nine Subject edits failed it. If you want to see why only the listed headers count, the email authentication lab shows DKIM and DMARC verdicts for mail sent directly and through forwarders.

This does not break anything today, because, per Resend's guide, no client reads the header yet. It matters for whoever builds the first reader: a DKIM pass on the message is not proof that the OTP-Token value came from the signer. The draft lists this as open. Its Security Considerations section opens with "TODO. Probably something about DKIM?", and its third open question asks whether to "only accept origin bindings that can be authenticated via DKIM/DMARC". The repo's test/dkim-coverage.test.js signs a message twice with a local key, once with otp-token in h= and once without, and shows that only the first one fails DKIM when the header is forged. We did not test signing messages ourselves before handing them to either provider.

Part 3: Chrome's Email Verification API, end to end

The Email Verification API skips the email entirely. The user is signed in to their mail provider in the same browser profile. Your form has a hidden field:

<input id="email" name="email" type="email" autocomplete="email" required />
<input
  type="hidden"
  name="token"
  autocomplete="email-verification-token"
  nonce="<per-form nonce>"
/>

When the user leaves the email field, Chrome looks up _email-verification.<domain> in DNS, finds the issuer, checks for a session, and asks the issuer for a signed Email Verification Token (EVT). It binds that token to your origin and the form's nonce in a Key Binding JWT (KB-JWT) and puts <EVT>~<KB-JWT> in the hidden field when the form is submitted. Your server checks both signatures, the DNS delegation, the email, the nonce and the audience. Chrome's Email Verification documentation lists the origin trial as Chrome 150 to 160 on desktop and 154 to 160 on Android, with Gmail as a participating provider.

How we ran it

We do not have a test Google account, so we used the mock issuer that Chrome's docs point to for testing: https://rowan.fyi/made/email-provider/, which signs you in as [email protected]. The browser was Chrome for Testing 159.0.8154.6 from Playwright 1.65.1, on a test server under Xvfb. Two setups:

  • Our verifier on http://localhost:8787, with the feature turned on by --enable-features=EmailVerificationProtocol (the feature name listed on Chrome Platform Status), because we have no origin trial token.
  • The docs' verifier demo at https://rowan.fyi/made/email-verification/, with no flag. The page carries an origin trial meta tag; we did not record whether the trial was active beyond the result the page showed.

The browser made these requests after the email field lost focus, recorded by 05-evp-browser.js:

The first time an address is verified, Chrome shows a prompt. This is our own localhost page with the flag on:

Chrome prompt on a sign-up form: "Verify this email automatically? While you're signed in, rowan.fyi can confirm demo@rowan.fyi on supported sites so you don't have to check your inbox", with Not now and Verify buttons

The prompt is browser UI, outside the page, so Playwright cannot click it. To accept it, the script sends a synthetic X11 click at the Verify button's screen position, read from the screenshot. That is a lab stand-in for a person, not a way to automate the prompt in production. One run per row:

Run Prompt answer Token received by the server on submit Result
Our verifier, headless none no Fell back to a code (dev mode prints it)
Our verifier, headed, prompt ignored none no Fell back to a code (dev mode prints it)
Our verifier, headed, Verify clicked synthetic click yes, 781 characters Verified by our src/evt.js, no email sent
Docs demo, prompt ignored none no Demo shows "No verification token was sent"
Docs demo, Verify clicked synthetic click yes Demo shows "Email successfully verified"

So the API did what it says, and the fallback matters. A user who ignores the prompt, or submits before the issuance request finishes, sends an empty field, and your form has to treat that as "send a code".

The verifier snippet in Chrome's guide skips the key binding

Chrome's verifier guide (read on 28 November 2026) gives example verification code for Node.js. It ends with:

// The library automatically verifies EVT signature, KB-JWT signature, audience, nonce, and sd_hash
const result = await sdJwt.verify(rawToken, {
  kb: {
    expectedNonce: sessionNonce,
    expectedAudience: 'https://example.com',
    required: true,
  },
});

verify() in @sd-jwt/core does not read a nested kb option. It reads keyBindingNonce and expectedKeyBindingAudience, and when keyBindingNonce is missing it returns after verifying the issuer's signature and claims, without looking at the KB-JWT. The KB-JWT signature, the nonce, the audience and sd_hash are not checked. (The library does use a kb option elsewhere, in present(), which creates presentations.) The repo's 08-sd-jwt-versions.sh prints the relevant source lines and runs the snippet test for 0.24.3 and 0.25.1; the result is the same in both. In 0.25.1 the class is also renamed from SDJwtInstance to SdJwtInstance, so the snippet's import fails there as published, and the test renames the import to run it.

Then we took the token Chrome minted in the run above and fed it to a replay harness, 07-replay-real-token.js, which calls our verifier and the snippet (copied as published) with the expected values another session or another site would use:

Presented as Our verifyEvt Snippet from the guide
Same site, same session accepted accepted
Same site, another session (replay) rejected: Invalid Nonce accepted
Another site, another nonce rejected: Invalid Nonce accepted
Another site, the token's own nonce rejected: Invalid Key Binding audience accepted

The snippet hardcodes https://example.com as the audience, and the token was minted for http://localhost:8787. It still passed. For a site using this code, that means a token minted for some other site, for example one captured by that site, would be accepted as proof of the address.

Fair context: the guide's step 2 lists nonce and audience as values you must check, and the code behind the guide's own verifier demo passes keyBindingNonce and expectedKeyBindingAudience correctly. The problem is only for code that copies the final snippet and trusts its comment. The fix is two option names:

// Wrong: verify() ignores this object and skips key binding
await sdJwt.verify(rawToken, {
  kb: { expectedNonce: nonce, expectedAudience: origin, required: true },
});

// Right: these are the options verify() reads
const result = await sdJwt.verify(rawToken, {
  keyBindingNonce: nonce, // without it, verify() returns before the KB-JWT
  expectedKeyBindingAudience: origin,
});
if (!result.kb) throw new Error('key binding was not verified'); // fail closed

Our src/evt.js does that. It also requires typ: evt+jwt, an audience that is a bare origin, the DNS delegation and an age limit on both JWTs. The same class of mistake, validating a token's signature but not its audience, is on the common mistakes list in the OWASP authentication chapter, and the OAuth and OIDC flow simulator shows why nonce and aud exist in ID tokens.

One more trap if you write this verifier yourself: it makes outgoing requests based on the token. The guide's discovery steps fetch https://<issuer>/.well-known/email-verification and then whatever jwks_uri that document names. Do not fetch anything for the token's iss until the _email-verification TXT record of the submitted email's domain names that issuer. Even then, whoever owns the email domain controls that record, so they can point it at an internal host. Our verifier only contacts https hostnames on the default port, checks every resolved address when it connects (no loopback, private, link-local or cloud metadata ranges, and no IPv6 form that embeds an IPv4 address), follows no redirects, caps the response at 64 KB, and stops the whole verification when the server's 10 second deadline passes. jwks_uri must be on the issuer's own origin, except for the Gmail key host that Chrome's guide documents. If you only expect Gmail users, an allowlist of issuers (EVP_ALLOWED_ISSUERS=https://accounts.google.com in the demo) is simpler still. The tests cover a forged iss, an IP literal issuer, an off-origin and an http jwks_uri, private, loopback and IPv4-embedding IPv6 addresses, redirects, a slow trickle response, size limits and cancellation.

Part 4: WebOTP has no email transport

Resend's guide guesses that email may join SMS as a WebOTP transport, so that a page could call navigator.credentials.get({ otp: { transport: ["email"] } }). The guide labels this as speculation. Today the browser rejects the value:

We aborted the sms request after 3 seconds without receiving a credential; no phone was linked. The email request was rejected immediately (0 ms), because email is not a transport the API knows. So in Chrome 159, WebOTP cannot read an emailed code. Of the pieces we tested, the browser path that skips typing a code is the Email Verification API, which does not use a code at all.

What we could not test, and why

  • Gmail's "Copy code" button. We have no Gmail test inbox of our own, and we only send tests to inboxes we own. The message builder has five layouts (plain, boxed, spaced, subject-only, no-keyword), selectable with OTP_LAB_LAYOUT, to compare once we have one. Until then we make no claim about which layout Gmail detects.
  • Receiving services other than Amazon SES, such as Gmail and Outlook.com, which may rewrite, drop or reorder unknown headers. One SES-to-SES path is all we measured.
  • Mail clients such as Apple Mail and Outlook, and anything they show for these messages.
  • Why the Resend duplicate-header message did not arrive. Our Resend key can only send.
  • Gmail as the Email Verification issuer, and Google Chrome stable. We used the docs' mock issuer and Chrome for Testing 159. Gmail needs a signed-in Google account.
  • Our own origin trial token. Our verifier ran with a command-line flag on localhost. The docs demo ran without a flag on a page that carries an origin trial meta tag; we did not record the trial's activation status directly.
  • Android and Safari. Not run.

What to ship this week

  1. Keep the emailed code, and do it properly: 6 digits, 10 minute expiry, 5 attempts, single use, stored as an HMAC, rate limited per address and per IP, checked against your own origin.
  2. Put the code alone on its own line, say which site it is for and when it expires, and use autocomplete="one-time-code" on the input.
  3. Add the OTP-Token header if your provider passes custom headers. Build it with a Structured Fields serializer, send exactly one, and do not rely on it for anything yet.
  4. If you join the Email Verification origin trial, treat the token as optional, fall back to a code when the field is empty, pass keyBindingNonce and expectedKeyBindingAudience to @sd-jwt/core, and guard the issuer fetches. Add a test that a token with the wrong nonce fails, because a verifier that cannot fail looks the same as one that works.
  5. If you build an OTP-Token reader, match the name case-insensitively, reject messages with two fields, and check that the DKIM signature you trust lists otp-token in h=.

The drafts may change or never ship, and even if they do, many users will not have the browser, the provider or the session they need. The emailed code has to stay available to every user, so it is the part to get right first. For a look at what happens underneath the send call, see sending an email by hand over raw SMTP.

Run the commands from this article in the browser. Nothing to install.

Published: 2026-12-02|Last updated: 2026-12-02T15:00:00Z

Tags

SecurityEmailAuthenticationDKIMChromeNode.js

Found an issue?

Also worth your time on this topic