Email Verification Codes: How OTPs Work and Why They Expire
What an email verification code really is, how one-time passwords are generated and checked, why they expire so fast, and what to do when a code never arrives.

An email verification code is a short, random secret that a website sends to your inbox to prove one thing: that whoever is typing at the keyboard can also read mail sent to that address. It is usually six digits, it works once, and it stops working after a few minutes. Everything else about it, including the expiry that catches people out, follows from that single job.
This guide explains what happens between clicking “Send code” and typing the digits, why the timer is so short, and how to work through the usual reasons a code does not show up.
What an email verification code actually proves
A sign-up form cannot see you. All it has is the text you typed, and anyone can type any address. So the site asks a question only the real owner of the inbox can answer: “We just sent a number to that address. What is it?”
If you answer correctly, the site learns that you control the mailbox right now. It does not learn your name, your age, or whether you are a person rather than a script. This is why email verification is often paired with other checks, and why the same mechanism shows up in several different places:
- Sign-up confirmation. Proves the address is real and yours before the account is activated.
- Login codes. A one-time password sent by email, used instead of or in addition to a password.
- Password resets. Proves you still control the address tied to the account.
- Sensitive changes. Confirming a new device, a new payout method, or a change of email.
The name changes from site to site (OTP email, security code, confirmation code, PIN) but the idea is the same.
How a one-time password is generated and checked
There is no clever mathematics in most emailed codes. The usual flow looks like this:
- You submit your address. The server generates a random number, typically six digits, using a cryptographically secure random source.
- The server stores a record: which account or session the code belongs to, a hashed copy of the code, when it was created, and how many wrong guesses have been made.
- It hands the email to its mail provider, which delivers it to your mail server like any other message.
- You type the code. The server looks up the record, checks that it has not expired, that the attempt limit has not been reached, and that the code matches.
- On success the record is deleted or marked used. The same digits will never work again.
That last step is what “one-time” means. A code that could be reused would be a second password, and a weak one.
Authenticator apps work differently. They use a shared secret plus the current time to calculate a new code every 30 seconds, following a public standard called TOTP (RFC 6238). Nothing is sent anywhere, which is why those codes work on a phone in aeroplane mode. An emailed code is simpler: it is just a random number the server remembers for a short while.
Why verification codes expire so quickly
Six digits gives one million possible codes. That sounds like a lot until you consider a script that can make thousands of guesses a minute. Three things keep a short code safe, and they work together.
A short lifetime. If a code is valid for ten minutes, an attacker has ten minutes. If it were valid for a week, they would have a week, and so would anyone who later gained access to an old email sitting in your inbox.
An attempt limit. Most systems allow only a handful of wrong guesses before the code is cancelled. With five tries out of a million possibilities, guessing is hopeless.
Single use. Once the right code is entered, it is dead. Someone who sees it over your shoulder a minute later gets nothing.
Expiry also limits the damage from mail that goes astray. Email is copied onto several servers on its way to you, may be synced to an old tablet in a drawer, and often stays in an inbox for years. A code that has been worthless since ten minutes after it was sent is harmless in all of those places.
How long is a code valid?
There is no universal rule. Each service sets its own, and they rarely publish it outside the email itself. In practice most emailed codes last somewhere between five and fifteen minutes, some stretch to thirty or sixty, and sign-up confirmation links often last a day or more because nothing sensitive sits behind them yet. The email usually says (“This code expires in 10 minutes”). If it does not, assume the short end and use it promptly.
One detail trips people up: on many sites, requesting a new code cancels the previous one. If you click “Resend” three times and then type the first code that arrived, it will be rejected even though it has not technically expired. Always use the most recent email.
Codes, magic links and authenticator apps compared
| Emailed code | Magic link | Authenticator app | |
|---|---|---|---|
| What you do | Read digits, type them in | Click a link in the email | Read digits from an app |
| Works across devices | Yes, read on phone and type on laptop | Awkward, the link opens where you click it | Yes |
| Depends on email delivery | Yes | Yes | No |
| Typical lifetime | Minutes | Minutes to hours | 30 seconds per code |
| Main weakness | Can be phished or read by anyone in your inbox | Link scanners may “click” it first | Losing the phone without backup codes |
A magic link is a verification code wearing different clothes. Instead of six digits, the secret is a long random string inside a URL, and clicking it submits the secret for you. Links are harder to guess and impossible to mistype. Their drawback is that corporate mail filters sometimes open every link in a message to check it for malware, which can use up a single-use link before you get to it. That is one reason many services have moved back to typed codes.
Verification code not received: what is usually wrong
When the code does not arrive, the cause is almost always one of a short list. Go through them in this order.
- Wait a full two minutes. Mail is not instant. The sender’s system may queue messages, and some receiving servers deliberately delay the first message from an unfamiliar sender (a technique called greylisting) so that it is retried a few minutes later.
- Check the address you typed. A missing letter or
.coninstead of.comis the most common cause by a wide margin. Go back and read it character by character. - Look in spam, junk and the other tabs. Gmail may file it under Promotions or Updates. Outlook may put it in Junk or “Other”.
- Search instead of scrolling. Search your mailbox for the site’s name or the word “code”. The message may be threaded under an older email from the same sender.
- Stop pressing Resend. Repeated requests can trigger a rate limit, after which the site silently sends nothing for a while. Request once, wait, then request once more.
- Check your own filters and blocks. A rule you created long ago, or a blocked sender, will quietly swallow the message.
- Check that the mailbox can receive at all. A full mailbox bounces new mail. Send yourself a test message from another account.
- Consider that the site has rejected the address. Some services refuse to send to disposable domains, and a few do so without showing an error. Our article on why websites block disposable emails explains how that works.
- Try a different address or method. If the site offers SMS or an authenticator option, use it, then contact support about the email problem.
If you are a developer testing your own sign-up flow and codes vanish, the problem is more often on the sending side: missing SPF or DKIM records, a sandboxed mail provider that only delivers to approved recipients, or a template that fails silently. Our guide to testing sign-up flows with temp mail covers that side.
Keeping codes safe: the rule that matters
A verification code is a key, and it should be treated as one. The most useful habit is simple:
Type a code only into the site or app where you started the action yourself. Never read one out, forward it, or paste it into a chat.
Scammers know they cannot guess a code, so they ask for it. A typical approach: someone starts a login or password reset on your account, which makes the genuine service send you a genuine code. Then they contact you, posing as support staff or a buyer on a marketplace, and ask you to “confirm the code we just sent”. The email is real. The request is the fraud. No legitimate company needs you to tell them a code they sent you.
Two more warning signs:
- A code you did not request. Somebody typed your address into a login or reset form. It may be a typo by a stranger, or it may be someone testing whether you have an account. Do nothing with the code. If it happens repeatedly on an important account, change that account’s password and review its security settings.
- A “verification” email that asks for more than a code. A real code email contains the code and little else. One that asks you to log in through a link to “see your code”, or to download something, is a phishing attempt. The checks in how to spot a phishing email apply here too.
It is also worth remembering what an emailed code is worth to an attacker who is already in your mailbox: everything. If someone controls your email, they can request a reset code for almost any account you own and read it themselves. Email-based verification is only as strong as the email account behind it, so that account deserves your longest password and a second factor that is not email.
Using verification codes with a temporary inbox
Receiving a one-off confirmation code is one of the most common reasons people open a temporary inbox: you want to read an article, download a file or try a tool, the site insists on confirming an address, and you have no interest in hearing from it again.
It works the same way as any other mailbox, with two things to keep in mind.
Timing. The code has a lifetime and so does the inbox. Open the temporary address first, request the code second, and keep the tab open until the code has arrived and been used. On TempMail Plus the default lifetime is one hour, which is longer than any normal code, and incoming codes are detected and shown with a copy button so you do not have to open the message and hunt for the digits.
Scope. A temporary address should only ever receive codes for accounts you are happy to lose. The same site that sends you a sign-up code today will send password-reset codes and “new device” codes to the same address later, and by then the inbox will be gone. That rules out banking, government services, healthcare, work accounts, your main social profiles and anything with money or history attached. If you might need the account next month, use your real address or a forwarding alias instead. The reasoning is laid out in more detail in how temp mail works.
There is a privacy point as well. On services where anyone who knows the address can open the inbox, a verification code is visible to whoever looks. We lock each inbox to the browser that created it for exactly this reason, but you should check how any service you use handles it before trusting it with a code.
Why some sites send a code and others send a link
You may notice the same company using codes in one place and links in another. The choice is usually practical:
- Codes suit cross-device use. You can start signing in on a television, a games console or a work laptop and read the code on your phone. A link would open on the wrong device.
- Links suit one-device, low-friction flows. Newsletter confirmations use links because a single click is all that is needed and nothing sensitive sits behind them.
- Codes survive link scanners. Security software cannot use up a code by reading the email.
- Codes are easier to phish. A person can be talked into reading six digits aloud. It is harder, though not impossible, to trick someone into handing over a link.
Neither is clearly better. What matters more is the lifetime, the attempt limit and whether the secret is single-use, and those are the same for both.
Quick answers
Can I reuse an old verification code?
No. A properly built system marks a code as used the moment it is accepted, and expires it shortly after sending even if it was never entered. If an old code works twice, the site has a security flaw.
Why did I get a code I did not ask for?
Someone entered your address into a login, sign-up or reset form. Often it is a typo by a person with a similar address. Occasionally it is an attempt to get into your account. The code is useless to them unless you hand it over, so ignore it, and tighten the account’s security if it keeps happening.
Is a six-digit code secure enough?
On its own, six digits would be weak. Combined with a lifetime of minutes and a limit of a few wrong guesses, it is strong against guessing. Its real weakness is people: codes are stolen by asking for them, not by cracking them.
Is it safe to receive a code in a temp mail inbox?
For a throwaway sign-up, yes, provided the inbox cannot be opened by someone who merely knows the address. For any account you want to keep or recover later, no. Use a permanent address you control.
The code arrived after it expired. What now?
Request a new one and stay on the page. If delays keep happening, the hold-up is between the sender and your mail server. Trying a different address at another provider is the quickest way to confirm that.
- email basics
- security
- accounts
- how-to


