Go SDK
Thesimpleemailapi-go package provides a fully typed, high-performance SDK for Go applications with real-time event streaming.
Language: Go 1.21+
Transport: HTTP/2 via Connect RPC
Transport: HTTP/2 via Connect RPC
Installation
Usage
Initialize the client with your API key and use theclient.Send method.
The
From address must belong to a domain you have verified.Client Configuration
TheNewClient function accepts optional configuration:
Your API Key, starting with
sea_live_.Sets a custom API endpoint. Defaults to
https://api.simpleemailapi.dev.Uses a custom
http.Client for requests.SendEmailRequest Fields
Sender email address. Must be from a verified domain.
List of primary recipient email addresses.
Email subject line.
Plain text content of the email.
HTML content of the email.
List of CC recipient email addresses.
List of BCC recipient email addresses.
List of files to attach.
Reply to a previous email using its
Id from our response. We automatically resolve threading headers.Raw Message-ID for threading (advanced). Use
ReplyTo for simpler threading with our email IDs.List of message IDs for threading context (advanced).
Custom key-value metadata returned in webhooks.
All emails are queued for reliable delivery with automatic retries. Use webhooks or event streaming to track delivery status.
Real-time Event Streaming
Stream email events with typed callbacks usingOnReceive:
The stream runs in a background goroutine and automatically reconnects with exponential backoff.
Available Event Handlers
| Handler | Description |
|---|---|
OnSent | Email accepted for delivery |
OnDelivered | Email delivered to recipient’s mailbox |
OnBounced | Email bounced (hard or soft) |
OnComplained | Recipient marked email as spam |
OnRejected | Email rejected before sending |
OnDelayed | Email delivery delayed |
OnReplied | Reply received to a sent email |
OnFailed | Email sending failed permanently |
OnError | Stream error occurred |
Error Handling
The SDK provides structured error handling with typed error codes:Error Categories
| Category | Range | Description |
|---|---|---|
CategoryAuth | 1xx | Authentication errors |
CategoryAuthz | 2xx | Authorization errors |
CategoryValidation | 3xx | Validation errors |
CategoryNotFound | 4xx | Resource not found |
CategoryDomain | 5xx | Domain verification errors |
CategoryRateLimit | 6xx | Rate/usage limit errors |
CategoryInternal | 9xx | Internal server errors |