Official Go SDK for Mail.td — temp mail & temporary email with REST API, webhooks, and custom domains. Instant inboxes, password protected, sign in from any device.
- Temp Mail API — Create and manage temporary email addresses programmatically
- Webhooks — Get notified in real-time when emails arrive
- Custom Domains — Use your own domain for branded temporary mailboxes
- Password Protected — Sign in to the same mailbox from any device
go get github.com/mailtd/mailtd-go/v2package main
import (
"context"
"fmt"
"log"
mailtd "github.com/mailtd/mailtd-go/v2"
)
func main() {
client := mailtd.NewClient("td_...")
ctx := context.Background()
// Create a temporary email address
pw := "mypassword"
account, err := client.Accounts.Create(ctx, "[email protected]", &mailtd.CreateOptions{
Password: &pw,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Created account: %s\n", account.Address)
// List messages
result, err := client.Messages.List(ctx, account.ID, nil)
if err != nil {
log.Fatal(err)
}
for _, m := range result.Data {
fmt.Printf("%s: %s\n", m.From, m.Subject)
}
}- Automated testing — Create temp mail addresses in CI/CD to test signup flows, OTP verification, and transactional emails
- Email verification testing — Validate that your app sends the right emails with the right content
- QA environments — Give each test run its own mailbox, then tear it down
All API calls require a Pro API Token (td_...). Pass it when creating the client:
client := mailtd.NewClient("td_...")// Custom base URL
client := mailtd.NewClient("td_...", mailtd.WithBaseURL("https://custom.api.url"))
// Custom HTTP client
client := mailtd.NewClient("td_...", mailtd.WithHTTPClient(&http.Client{
Timeout: 30 * time.Second,
}))| Resource | Description |
|---|---|
client.Accounts |
Create, get, delete accounts; reset password; list domains |
client.Messages |
List, get, delete messages; attachments; mark as read |
client.Domains |
Pro: manage custom domains |
client.Webhooks |
Pro: manage webhooks |
client.Tokens |
Pro: manage API tokens |
client.Billing |
Pro: subscription management |
client.User |
Pro: user profile and account management |
API errors are returned as *mailtd.APIError:
import "errors"
_, err := client.Accounts.Get(ctx, "invalid-id")
if err != nil {
var apiErr *mailtd.APIError
if errors.As(err, &apiErr) {
fmt.Printf("Status: %d, Code: %s, Message: %s\n", apiErr.Status, apiErr.Code, apiErr.Message)
}
}- Website — Temp mail & temporary email with REST API
- API Documentation — Full API reference
- Node.js SDK —
npm install mailtd - Python SDK —
pip install mailtd - CLI — Command-line tool
MIT