Zapmail processes incoming emails through a custom SMTP server and displays them in a web interface. This page explains the complete email flow from reception to viewing.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Parth-420/Zapmail/llms.txt
Use this file to discover all available pages before exploring further.
Email flow overview
SMTP server receives email
When someone sends an email to
username@zapmail.parth.lol, it arrives at Zapmail’s custom SMTP server running on Go. The server accepts the connection and responds with a greeting:SMTP handshake
The SMTP server processes standard SMTP commands in sequence:
HELOorEHLO- Establishes the connectionMAIL FROM- Identifies the senderRCPT TO- Specifies the recipient (e.g.,<username@zapmail.parth.lol>)DATA- Indicates the start of the email content
Email data collection
After receiving the
DATA command, the server collects all email content line by line until it encounters a single period (.) on a line by itself. This raw email data includes:- Email headers (From, To, Subject, Date, etc.)
- MIME parts and content-type information
- HTML and plain text body content
- Any attachments or embedded images
Username extraction
The server extracts the username from the recipient address by:
- Removing angle brackets (
<and>) - Splitting on the
@symbol - Taking the first part as the username
<john@zapmail.parth.lol> becomes john.Database storage
The email is stored in a PostgreSQL (Supabase) database with the following information:
username- The extracted username portionrecipient- The full recipient address with angle bracketsraw_data- The complete raw email contentreceived_at- Timestamp of when the email was received
Web interface retrieval
When you visit your inbox at
/user?q=username, the web application:- Queries the database for all emails where
recipient = <username@zapmail.parth.lol> - Parses each raw email using the
mailparserlibrary - Extracts structured data (subject, from, body, attachments, date)
- Displays emails in reverse chronological order (newest first)
Technical architecture
SMTP server (Go)
The backend SMTP server handles concurrent connections using goroutines. Each incoming connection is processed independently:The server supports multiple simultaneous email deliveries without blocking, making it efficient for handling high volumes of incoming mail.
Email parsing
Raw email data is stored as-is in the database. When you access your inbox, the Next.js application parses the raw email to extract:- Subject line - The email’s subject
- From address - Sender’s email address and name
- Date - When the email was sent
- Text content - Plain text version of the email body
- HTML content - Rich HTML version for display
- Attachments - Any files attached to the email
Supported SMTP commands
Zapmail’s SMTP server implements the following commands:Core commands
Core commands
HELO/EHLO- Identify the client to the serverMAIL FROM- Specify the sender’s email addressRCPT TO- Specify the recipient’s email addressDATA- Begin transmission of email contentQUIT- Close the connection
Optional commands
Optional commands
NOOP- No operation (keeps connection alive)HELP- Lists supported commandsVRFY- Verify an email address (returns “not supported”)EXPN- Expand a mailing list (returns “not supported”)
Any unrecognized SMTP command receives a
500 Unrecognized command response, ensuring compatibility with standard SMTP clients.Response codes
The SMTP server uses standard response codes:- 220 - Service ready (initial greeting)
- 250 - Requested action completed successfully
- 354 - Start mail input (after DATA command)
- 221 - Service closing connection (after QUIT)
- 500 - Command not recognized
- 550 - Error (e.g., failed to store email)