Quick Start
Here’s how to send a batch of emails:Batch Send Methods
The SDK provides three methods for sending batch emails:Batch Validation Modes
The SDK supports two validation modes for batch email sending:Strict Mode (Default)
In strict mode, the entire batch fails if any email has validation errors:Use strict mode when all emails in the batch must be sent together (all-or-nothing behavior).
Permissive Mode
In permissive mode, valid emails are sent even if some emails in the batch have errors:BatchSendEmailOptions
TheBatchSendEmailOptions struct supports the following fields:
string
Unique key to prevent duplicate batch sends. Valid for 24 hours.
BatchValidationMode
Validation mode:
BatchValidationStrict (default) or BatchValidationPermissive.- Strict: All emails must be valid or entire batch fails
- Permissive: Valid emails are sent, invalid ones are reported in errors
BatchEmailResponse
The response from a batch send includes:[]SendEmailResponse
Array of successfully sent emails with their IDs.
[]BatchError
Array of errors for emails that failed validation (only in permissive mode).
Handling BatchErrors
In permissive mode, failed emails are reported in theErrors field:
BatchError Struct
int
Zero-based index of the failed email in the original batch array.
string
Error message describing why the email failed validation.
Using Idempotency Keys
Prevent duplicate batch sends with idempotency keys:Idempotency keys are valid for 24 hours. After that, the same key can be reused.
Common Use Cases
Welcome Email Campaign
Welcome Email Campaign
Notification Broadcast
Notification Broadcast
Transactional Emails with Templates
Transactional Emails with Templates
Processing Large Batches
For large email lists, split them into smaller batches:Error Handling
Handle both request errors and validation errors:Best Practices
1
Choose the Right Validation Mode
Use strict mode for critical transactional emails where consistency matters:
2
Use Idempotency Keys
Always use idempotency keys for batch sends to prevent duplicates on retry:
3
Add Tags for Tracking
Tag batch emails for better analytics and debugging:
4
Handle Partial Failures
In permissive mode, always check and log validation errors:
5
Batch Size Optimization
Keep batches to 100-500 emails for optimal performance:
6
Rate Limit Awareness
Add delays between batches if sending many batches in succession:
Validation Mode Comparison
Source: batch.go:9
Next Steps
Sending Emails
Learn single email sending basics
Email Templates
Use templates in batch emails
Scheduled Emails
Schedule batch emails for later
Attachments
Add attachments to batch emails