https://rustmailer.com/docs/blog/integrate-rustmailer-search-crm
The RustMailer /unified-search API enables rapid email searches within a local cache, supporting queries based on email address, time range, and account scope. This API avoids real-time IMAP server connections by leveraging a pre-built index table, making it ideal for integration with CRM systems, customer support platforms, or sales management tools.

In a CRM, you often need to:
Display recent email interactions on a customer’s profile page.
Quickly locate all communications for a customer across multiple email accounts.
Filter emails by time range or communication direction (from/to).
The /unified-search API allows your CRM to retrieve emails from multiple accounts in a unified manner without dealing with underlying IMAP protocols, delivering millisecond-level response times.
POST /api/v1/unified-search
Request Parameters (Query):
ParameterTypeDescriptionpageu64Current page number (starts at 1)page_sizeu64Number of emails per pagedescboolSort by time in descending order (default: ascending)
Request Body (JSON):
{
"email": "customer@example.com",
"after": 1719859200000,
"before": 1722451200000,
"accounts": [1, 2, 5]
}
after/before: Optional time range (UTC milliseconds).
accounts: Optional list of email account IDs; if omitted, includes all accessible accounts.
curl -X POST https://your-server/api/v1/unified-search?page=1&page_size=50&desc=true \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"email": "alice@example.com",
"after": 1720000000000,
"before": 1720500000000
}'
The /unified-search API relies on RustMailer’s internal email index table, which stores metadata such as subjects, sender, recipient, and timestamps, without caching full email content or attachments during synchronization. This enables sub-second response times, even with millions of cached emails, supporting efficient paginated searches. The API returns a list of email metadata, allowing users to view a list of email subjects. When a user clicks to view an email’s content, RustMailer uses a separate API to fetch the email body and attachments from the IMAP server. These are cached on RustMailer’s local disk to avoid redundant IMAP fetches, with automatic cleanup to manage storage efficiently.
If you have any questions or need further assistance, feel free to reach out via GitHub Discussions or join our community on Discord. If you find RustMailer useful, give it a try and consider starring the project on GitHub!