Skip to main content

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.

Zapmail provides server actions for searching and parsing emails stored in the database.

searchEmails

Searches for emails sent to a specific username and returns parsed email data. Function signature:
async function searchEmails(rcptQuery: string)

Parameters

rcptQuery
string
required
The username portion of the email address to search for (without the @zapmail.parth.lol domain).The function automatically formats this into the full recipient address with angle brackets.Example: "user123" is formatted to "<user123@zapmail.parth.lol>"

Returns

output
array
An array of email objects, ordered by received date (most recent first).
id
number
Unique database identifier for the email.
date
Date
Timestamp when the email was received by the server.
mail_from
string
The username extracted from the recipient field.
rcpt_to
string
The full recipient address in angle bracket format.
data
EmailContent
The parsed email content object returned by parseEmail.

Example

import { searchEmails } from "@/app/actions/actions";

const emails = await searchEmails("user123");
// Returns array of emails sent to user123@zapmail.parth.lol

Error handling

Throws an error if the database query fails. Individual email parsing errors are logged but do not stop processing of other emails. Source: ui/src/app/actions/actions.ts:6-49

parseEmail

Parses raw email data into a structured format using the mailparser library. Function signature:
async function parseEmail(data: string): Promise<EmailContent>

Parameters

data
string
required
Raw email data in RFC 822 format (headers and body).This is typically the raw SMTP DATA content stored in the database.

Returns

EmailContent
object
A parsed email content object.
subject
string
The email subject line. Empty string if not present.
from
string
The sender’s email address in text format. Empty string if not present.
text
string
Plain text version of the email body. Empty string if not present.
html
string
HTML version of the email body. Empty string if not present.
text_as_html
string
Plain text converted to HTML format. Empty string if not present.
attachments
Attachment[]
Array of email attachments. Empty array if no attachments.
date
Date
The date from the email headers. Defaults to current date if not present.

Example

import { parseEmail } from "@/hooks/emailParser";

const rawEmail = `Subject: Test
From: sender@example.com

Hello World`;

const parsed = await parseEmail(rawEmail);
console.log(parsed.subject); // "Test"
console.log(parsed.from); // "sender@example.com"
console.log(parsed.text); // "Hello World"

Error handling

Throws an error if the email cannot be parsed. The error is logged to the console before being thrown. Source: ui/src/hooks/emailParser.ts:13-30

Build docs developers (and LLMs) love