Receiving Emails
Relevant source files
The following files were used as context for generating this wiki page:
- src/main/java/com/resend/services/receiving/Receiving.java
- src/main/java/com/resend/services/receiving/model/ReceivedEmail.java
- src/main/java/com/resend/services/receiving/model/ReceivedEmailSummary.java
- src/main/java/com/resend/services/receiving/model/ListReceivedEmailsResponse.java
- src/test/java/com/resend/services/receiving/ReceivingTest.java
The Receiving module manages inbound emails sent to your Resend domains. It allows you to retrieve, list, and inspect emails received by the system, including their metadata, content, and attachments.
This module provides a programmatic interface to interact with the Resend inbound infrastructure. You use it to track emails received for forwarding or processing, fetch specific message details like HTML or plain text content, and access individual file attachments.
Sources: src/main/java/com/resend/services/receiving/Receiving.java:13-16, src/main/java/com/resend/services/receiving/model/ReceivedEmail.java:9-11
Core Service Methods
The Receiving class serves as the primary entry point for managing received emails. It extends BaseService and uses an HTTP client to communicate with the Resend API.
| Method | Description | Return Type |
|---|---|---|
get(emailId) | Retrieves a single received email by its ID. | ReceivedEmail |
list() | Retrieves a list of all received emails. | ListReceivedEmailsResponse |
list(params) | Retrieves a paginated list of received emails. | ListReceivedEmailsResponse |
getAttachment(emailId, attachmentId) | Retrieves details for a specific attachment. | AttachmentDetails |
listAttachments(emailId) | Lists all attachments for a specific email. | ListAttachmentsResponse |
Sources: src/main/java/com/resend/services/receiving/Receiving.java:42-106
Data Flow for Email Retrieval
The following diagram illustrates the interaction between the SDK and the Resend API when fetching received email data.
Data Models
The system differentiates between a detailed view of an email and a summary view used for listing multiple emails to optimize performance.
ReceivedEmail
This model contains the full content of an inbound email.
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier for the received email. |
from | String | Sender address. |
to | List<String> | Primary recipient addresses. |
subject | String | Email subject line. |
html | String | The HTML body content. |
text | String | The plain text body content. |
headers | Map<String, String> | Key-value pairs of email headers. |
received_for | List<String> | Addresses the email was received for (forwarding). |
attachments | List<ReceivedEmailAttachment> | List of file metadata. |
Sources: src/main/java/com/resend/services/receiving/model/ReceivedEmail.java:13-58
ReceivedEmailSummary
Used in list() operations, this class omits high-volume fields like html, text, and headers.
Attachment Handling
Inbound emails can contain multiple attachments. The SDK provides methods to list these attachments or retrieve specific details, including temporary download URLs.
- List Attachments: Call
listAttachments(emailId)to get a collection ofReceivedEmailAttachmentobjects containing basic metadata like filename and content type. - Get Attachment Details: Call
getAttachment(emailId, attachmentId)to retrieve anAttachmentDetailsobject. This includes adownloadUrland anexpiresAttimestamp indicating when the link becomes invalid.
Sources: src/main/java/com/resend/services/receiving/Receiving.java:80-106, src/test/java/com/resend/services/receiving/ReceivingTest.java:125-144
Summary
The Receiving module provides essential tools for monitoring and processing inbound communication. By utilizing the Receiving service, you can integrate inbound email workflows into your Java applications, allowing for automated response systems, email archival, or custom forwarding logic based on received content and attachments.