Receiving & Inbound Email
Relevant source files
The following files were used as context for generating this wiki page:
The Receiving service manages inbound email handling within the Resend ecosystem. It provides the necessary infrastructure to list received messages, retrieve specific email content, and access attachments sent to your domains.
Sources: CHANGELOG.md:19, receiving.go
Inbound Email Retrieval
You can access emails sent to your configured domains through the Emails.Receiving sub-service. The system supports fetching individual emails by their unique identifier or listing all received messages with pagination support.
Email Data Structure
A received email object contains comprehensive metadata and content, including the sender, recipients, and raw message details.
| Field | Type | Description |
|---|---|---|
Id | string | Unique identifier for the received email |
From | string | The sender's email address |
To | []string | List of primary recipients |
Subject | string | The subject line of the email |
Html | string | The HTML content of the message |
Text | string | The plain text content of the message |
CreatedAt | string | Timestamp of when the email was received |
Raw | RawEmail | Contains download URL and expiry for the raw message |
Sources: receiving.go:34-60, receiving_test.go:17-49
Retrieval Flow
The following diagram illustrates the process of retrieving a received email and its components:
Attachment Management
The service provides specialized methods for handling files attached to inbound emails. You can list all attachments for a specific message or retrieve full details for a single attachment, including temporary download URLs.
Attachment Methods
| Method | Purpose |
|---|---|
GetAttachment | Retrieves details and a download URL for a specific attachment |
ListAttachments | Returns a list of all attachments associated with an email |
Sources: receiving.go:151-175, examples/receiving.go:56-85
Download Security
When you request attachment details, the API generates a DownloadUrl. This URL is temporary and expires at the time specified in the ExpiresAt field.
Sources: receiving_test.go:214-230, receiving.go:78-88
Inboxes and Drafts
The project supports advanced inbound workflows through the Inboxes service. This allows you to create managed email addresses on your domains and interact with inbound threads.
Managed Inbox Operations
You can create inboxes for specific functions, such as customer support, and manage them programmatically.
- Create an inbox using
client.Inboxes.Create. - Retrieve unread thread counts with
client.Inboxes.Get. - Search through inbound threads using
client.Inboxes.Threads.Search. - Archive or remove threads to manage the inbox state.
Sources: examples/inboxes.go:17-106
Replying to Inbound Mail
The system allows you to reply to received messages by creating drafts or sending replies directly.
- Direct Reply: Use
client.Inboxes.Threads.Emails.Replyto send an immediate response. - Drafting: Use
client.Inboxes.Drafts.Createto save a response for later review. - Idempotency: When sending drafts, you can provide an
IdempotencyKeyto prevent duplicate sends during retries.
Sources: examples/inboxes.go:121-149, inbox_drafts_test.go:207-223
Technical Summary
The Receiving service enables developers to build interactive email applications by providing structured access to inbound traffic. By combining the Receiving API for content retrieval with the Inboxes service for state management and replies, you can automate complex email workflows and handle attachments securely through signed, expiring URLs.