How Does Temporary Email Work? One Message's Path Through Our Servers
How temporary email works, traced through the code that runs PureTempMail: one message from the SMTP handshake to your screen, then to deletion.
PureTempMail Team
The engineers who build and run PureTempMail

Temporary email works like any inbound mail server with a short memory. A sender's server connects to ours over SMTP, we check that the address belongs to a live mailbox, then we queue, parse and store the message, push it to your open tab, and delete all of it once the mailbox expires.
This is the engineering version, written by the people who run PureTempMail and taken from the code that serves this site. For each hop: what the server does, why we built it that way, and where it bit us. The non-technical tour is on How it works.
Short answer
A temp mail service accepts SMTP mail only for addresses it generated, stores each message against a mailbox with an expiry time, shows new mail in your browser in real time, and permanently deletes the mailbox and its files when the timer runs out. PureTempMail never sends mail.
1. The SMTP handshake
Mail arrives at a Haraka server, an open-source SMTP server written in Node.js, listening on port 25. We offer STARTTLS with TLS 1.2 as the minimum, but we don't refuse senders that skip encryption: turning away a plaintext sender would only lose the verification email you were waiting for. Idle connections are dropped after five minutes.
Message size is capped at 1 MB (1,048,576 bytes). Haraka enforces the cap while the message is being transmitted, and the API checks it again before parsing. A megabyte is plenty for sign-up confirmations, receipts and small PDFs, and it keeps a free throwaway address from turning into file storage.
Why the server only receives
Outbound delivery is switched off in the SMTP configuration, and no code path sends mail. That removed most of the ways a free email service gets abused: nobody can send spam or phishing from a PureTempMail address, and our IP addresses never land on blocklists for outgoing abuse. The cost is that you cannot reply to anything. For a sign-up confirmation that is fine. For a conversation, use a real address.
2. The recipient check at RCPT TO
Before the sender transmits a single byte of the message, it names the recipient with an RCPT TO command. Our Haraka plugin passes that address to an internal API endpoint, which looks the mailbox up in PostgreSQL. The endpoint answers only requests that come from the loopback interface, and it checks this at the TCP socket, not from request headers a client could forge.
The check has three possible outcomes:
- The mailbox exists and has not expired. We accept the recipient, and the sender goes on to transmit the message.
- No such mailbox, or it has expired. We reply with a permanent 550 rejection. The message body never crosses the wire.
- The lookup itself fails, for example while the API restarts. We reply with a temporary 4xx failure. The sending server keeps the message and tries again later, which is how SMTP is designed to handle a busy recipient.
Why we reject early instead of accepting and dropping
The easy design is a catch-all: accept mail for any address on the domain and throw away whatever nobody claimed. We rejected it for three reasons. A catch-all tells the sender a message was delivered when it was not, so someone who mistyped an address never finds out. It makes us download and parse every message spammers aim at random addresses. And a server that accepts first and fails later is required by RFC 5321 to send a bounce to the sender's return address, which for spam is usually forged and belongs to someone innocent. Rejecting at RCPT time leaves the message with the sending server, which tells its own user.
This check is also where expiry takes effect for incoming mail. The moment your mailbox's timer runs out, new mail to that address is refused, even if the cleanup job has not yet deleted what was stored.
3. A queue between receiving and processing
Once the recipient is accepted and the message arrives, the SMTP plugin does no parsing. It streams the raw bytes into a buffer, bundles them with the recipient list and a timestamp, and publishes the bundle to a durable RabbitMQ queue as a persistent message. Haraka answers the sender with 250 OK after the hand-off. If RabbitMQ is unreachable, the sender gets a temporary failure and retries.
Why we don't parse inside the SMTP server
A sending server waits for our reply with a timeout. Parsing a message with attachments, writing files and inserting rows takes longer and fails in more ways than reading bytes off a socket. The queue lets the SMTP side answer quickly and lets the API work through a burst at its own pace. The consumer takes one message at a time and acknowledges it only after the message is stored, so if the API process dies halfway through, RabbitMQ hands the same message out again.
4. Parsing and storage
The API consumer decodes the raw message with postal-mime, a MIME parser with no dependencies. It pulls out the sender, subject, plain-text body, HTML body and attachments. Then, for each recipient on our domain, it checks again that the mailbox is still alive, because a message can wait in the queue for a moment and a mailbox can expire during that moment.
Each mailbox holds up to 50 messages and 5 MB in total, and we store at most 10 attachments per message. Text and HTML go into PostgreSQL. Attachments go to disk in one folder per message, each file named with a random UUID and a cleaned-up extension. The filename the sender chose is kept only as a display label and never used as a path, which shuts out tricks like an attachment named ../../config. A message addressed to two of our mailboxes is stored once for each.
5. Real-time delivery with Server-Sent Events
When the row is written, the API emits an event for that mailbox. Your browser holds an open Server-Sent Events connection to the mailbox's stream endpoint, and the event goes straight down it as a small JSON summary: sender, subject, time received and size. The full message is fetched only when you open it, and that fetch marks it read. Our mobile apps listen to the same stream and can also show a push notification.
Why SSE and not polling or WebSockets
Polling spends requests on an inbox that is empty most of the time and still adds delay. WebSockets would work, but data only flows one way here. SSE is plain HTTP, passes through our nginx proxy, and browsers reconnect it on their own.
Long-lived connections fail in their own ways. Every 30 seconds the server writes a comment line, a line starting with a colon that the browser ignores, so proxies don't close the connection as idle. The HTML standard's notes on server-sent events recommend this exact trick. We also send a header that tells nginx not to buffer the response; before we added it, events sat in the proxy's buffer and arrived late. Once a minute the server checks whether the mailbox has expired and closes the stream if it has. Each IP can hold only a few streams open at once, and each stream has a maximum lifetime, after which the client reconnects with backoff.
6. Rendering in your browser
Opening a message loads its HTML into an iframe with the sandbox attribute, and the only permission we grant is opening links in a new tab. As MDN's iframe reference describes, that means scripts inside the email do not run, its forms cannot submit, and the frame gets a special origin that fails every same-origin check. The email cannot read the page around it or the browser storage that holds your mailbox ID.

Remote images do load when a message opens in its HTML view, which is the default, as they do in most webmail. That includes tracking pixels. The sender's server sees a request for its image, so it learns that someone opened the message and sees the IP address the request came from. What it can tie that to is a random address that will not exist in an hour. A toggle in the message view switches to the plain-text version, which loads nothing remote, but the HTML view has already loaded by the time you switch.

Why a sandbox and not a Content Security Policy
A Content Security Policy on the frame could also stop image loads. We chose the sandbox on its own. One attribute disables the dangerous part of HTML email, active content, and the message still looks the way its sender designed it, which matters when you are hunting for a confirmation button in a heavily styled template. The cost is the one described above: in HTML view, images load, pixels included.
7. Expiry and deletion
A mailbox starts with one hour. Extending it resets the timer to one hour from now, but never past 24 hours from creation, so no mailbox lives forever. At expiry the API stops serving it: message requests get HTTP 410 Gone, the live stream closes, and SMTP refuses new mail.
A cleanup job runs every five minutes. It finds expired mailboxes, collects every attachment path in one query, deletes those folders from disk, then deletes the mailbox rows; their messages and attachment records go with them through cascading foreign keys. Rows are hard-deleted, with no archive table and no soft-delete flag. An expired mailbox's content stays on disk for one sweep interval at most, and nothing will show it to you in that window.
Why files first, then rows
Order matters whenever a process can crash between two steps. If we deleted the rows first and crashed before removing the files, the database would no longer know those files existed, and they would stay on disk forever with nothing pointing at them. Deleting files first means a crash leaves rows that point at folders already gone. The next run finds the same expired mailboxes, removing an already-missing folder succeeds quietly, and the rows go. A crash costs us a retry, never an orphaned file.
The tradeoffs in one table
| Decision | What we gave up | What we got |
|---|---|---|
| Receive only | Replies and sending | No outbound spam, no blocklisted IPs |
| Reject unknown recipients at RCPT TO | A catch-all that accepts anything | Senders learn about bad addresses, no backscatter, less junk to parse |
| Queue between SMTP and parsing | A simpler single process | Fast SMTP replies, mail survives an API restart |
| One retry for failing messages | A guarantee that every malformed message gets processed | One bad email cannot stall the queue |
| Server-Sent Events for live updates | A two-way channel we don't need | Plain HTTP, automatic reconnects |
| Sandboxed frame without a CSP | Blocking remote images | Emails render as designed, no email script runs |
Spec sheet
The hard limits, as configured in production.
- Max message size
- 1 MB (1,048,576 bytes), checked at SMTP and again before parsing
- Mailbox lifetime
- 1 hour by default. Each extension resets it to 1 hour from now, capped at 24 hours from creation
- Per mailbox
- Up to 50 messages and 5 MB in total, with up to 10 attachments stored per message
- Deletion
- Sweep every 5 minutes: attachment files first, then database rows. No recovery
- Rate limits per IP, per minute
- 5 new mailboxes, 10 extensions, 60 reads, 10 live-stream connections, 30 attachment downloads
- Transport
- STARTTLS offered with TLS 1.2 as the minimum; plaintext senders still accepted
What this means when you use it
Two practical things follow. Mail sent after your timer runs out is refused at the door, so if a code is slow to arrive, extend the mailbox before it expires. And everything is gone within minutes of expiry, so copy anything you need, such as an order number, while the mailbox is alive.
Whether a throwaway inbox suits a particular sign-up is a separate question, covered in Is disposable email safe?. Some sites refuse temp addresses outright, and why websites block disposable email explains how they spot them. To watch this pipeline work, open a fresh address and send it something.
Sources: RFC 5321, Simple Mail Transfer Protocol; WHATWG HTML Standard, server-sent events; MDN, the iframe element; RabbitMQ consumer documentation; postal-mime on GitHub; Haraka on GitHub.