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:SendEmailRequest Fields
TheSendEmailRequest 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
- Text Only
- HTML Only
- Both
Using CC, BCC, and Reply-To
Adding Custom Headers
You can include custom headers for advanced email routing or tracking:Using Tags for Categorization
Tags allow you to add custom metadata to emails for categorization, filtering, and analytics: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:Listing Emails
Retrieve a list of recently sent emails:- Basic List
- With Pagination
- Cursor Pagination
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