Skip to main content
The Resend Go SDK provides multiple methods for sending emails with support for text, HTML, headers, tags, and more.

Quick Start

Here’s a simple example to send your first email:

Send Methods

The SDK provides three methods for sending emails, each with different levels of control:
Use SendWithContext when you need timeout or cancellation control. Use SendWithOptions when you need idempotency guarantees for retry logic.

SendEmailRequest Fields

The SendEmailRequest struct supports the following fields:
string
required
The sender email address. Must be a verified domain.
[]string
required
Array of recipient email addresses.
string
required
The email subject line.
string
Plain text version of the email content.
string
HTML version of the email content.
[]string
Array of CC recipient email addresses.
[]string
Array of BCC recipient email addresses.
string
Reply-to email address.
map[string]string
Custom email headers as key-value pairs.
[]Tag
Custom metadata tags for categorizing and tracking emails.
[]*Attachment
Array of file attachments. See Attachments guide.
string
ISO 8601 datetime to schedule email delivery. See Scheduled Emails guide.
*EmailTemplate
Template configuration for sending template-based emails. See Email Templates guide.

Sending Text and HTML Emails

Using CC, BCC, and Reply-To

Adding Custom Headers

You can include custom headers for advanced email routing or tracking:
Some header names are reserved and cannot be overridden (e.g., From, To, Subject).

Using Tags for Categorization

Tags allow you to add custom metadata to emails for categorization, filtering, and analytics:
Use tags to segment your email analytics and track performance by category, user segment, or campaign.

Idempotency Keys

Idempotency keys prevent duplicate email sends when retrying failed requests:
Idempotency keys are valid for 24 hours. Multiple requests with the same key within this window will return the same response without sending duplicate emails.

Retrieving Sent Emails

You can retrieve details about a sent email using its ID:
Source: emails.go:315

Listing Emails

Retrieve a list of recently sent emails:
Source: examples/send_email.go:53

Error Handling

Always check for errors when sending emails:

Best Practices

1

Use Context

Always use SendWithContext in production to enable timeout and cancellation control:
2

Provide Both Text and HTML

Include both Text and Html versions for better email client compatibility:
3

Use Idempotency Keys

Use idempotency keys for critical transactional emails to prevent duplicates:
4

Add Tags for Analytics

Use tags to categorize emails for better analytics and reporting:
5

Handle Rate Limits

Implement proper error handling for rate limits with exponential backoff:

Next Steps

Email Templates

Learn how to use reusable email templates

Attachments

Add file attachments to your emails

Batch Emails

Send multiple emails in a single request

Scheduled Emails

Schedule emails for future delivery