Email Sending & Batch Operations
Relevant source files
The following files were used as context for generating this wiki page:
Email sending and batch operations allow users to transmit messages through the Resend API using the CLI. This system supports single email delivery, bulk batch processing, template-based rendering, and scheduled delivery.
The CLI handles authentication via environment variables or stored profiles. It validates inputs locally before transmitting payloads to the Resend infrastructure.
Sources: SKILL.md:52-54, src/commands/emails/send.ts:160-164
Single Email Operations
The emails send command transmits individual messages. It requires a recipient and a content source. Content sources include plain text, HTML strings, local files, or React Email templates.
Input Validation and Processing
The CLI validates that required flags are present. If you omit the --from address in interactive mode, the CLI fetches verified domains and prompts for a selection.
The diagram shows the logic flow for preparing and sending a single email.
Sources: src/commands/emails/send.ts:153-200, tests/commands/emails/send.test.ts:98-115
Content Rendering
Users can send emails using three primary methods:
- Standard Body: Providing
--textor--htmldirectly. - File-based Body: Using
--text-fileor--html-fileto read content from disk or stdin. - React Email: Using
--react-email <path>to bundle and render.tsxtemplates locally before sending.
Sources: src/commands/emails/send.ts:60-80, skills/resend-cli/references/emails.md:12-20
Batch Email Operations
Batch operations process up to 100 emails in a single API request. This reduces network overhead for bulk transmissions.
Batch Execution Logic
You must provide a JSON file containing an array of email objects. The CLI normalizes snake_case aliases (like scheduled_at) to the camelCase format expected by the Resend SDK.
| Feature | Description |
|---|---|
| Limit | Maximum 100 emails per batch request. |
| Strict Mode | Fails the entire batch if one email is invalid. |
| Permissive Mode | Allows partial success; returns a list of failed indices. |
| Constraints | Attachments are not supported in batch operations. |
Sources: src/commands/emails/batch.ts:40-44, skills/resend-cli/references/emails.md:73-86, tests/commands/emails/batch.test.ts:178-185
Batch Data Flow
The sequence diagram illustrates the batch processing lifecycle from file parsing to API response.
Sources: src/commands/emails/batch.ts:70-130, tests/commands/emails/batch.test.ts:130-145
Scheduling and Management
The CLI supports scheduling emails for future delivery. You can provide dates in ISO 8601 format or natural language (e.g., "tomorrow at 9am").
Management Commands
- emails cancel: Stops a scheduled email from being sent.
- emails update: Modifies the delivery time of an existing scheduled email.
- emails get: Retrieves the status and metadata of a sent or scheduled email.
Sources: skills/resend-cli/references/emails.md:88-105, skills/resend-cli/references/workflows.md:38-42
Attachment Handling
The CLI supports attaching local files and remote URLs. You can specify metadata using a semicolon-delimited syntax.
Attachment Specification
User must quote values containing semicolons.
- Local Files: Read from disk and converted to Base64.
- URL Attachments: The API fetches these asynchronously after the initial request.
- Inline Images: Supported via the
;cid=parameter for referencing in HTML bodies.
| Parameter | Description | Example |
|---|---|---|
;filename= | Custom name for the attachment | report.pdf;filename=july.pdf |
;type= | Explicit MIME type | data.csv;type=text/csv |
;cid= | Content ID for inline images | logo.png;cid=brand |
Sources: src/commands/emails/send.ts:98-105, skills/resend-cli/references/emails.md:27-40
Dry-Run and Validation
The --dry-run flag allows you to validate payloads without consuming quotas or sending messages.
Behavior by Command
- emails send: Prints the serialized request JSON. Attachment content is replaced with
byteLengthto keep output readable. - emails batch: Prints the array of processed and normalized email objects.
Sources: SKILL.md:84-86, src/commands/emails/send.ts:20-40, tests/commands/emails/batch.test.ts:320-330
Summary
The Email Sending and Batch Operations module provides a robust interface for both individual and high-volume communication. By supporting React Email rendering and dry-run validation, the CLI ensures that developers can test and deploy complex email workflows directly from their terminal or CI/CD pipelines.
Sources: SKILL.md:145-150, skills/resend-cli/references/workflows.md:140-150