Skip to main content
Version: 0.3

goemail

Production-ready email package for Go with SMTP support, templating, retries, rate limiting, connection pooling, async sending, middleware, DKIM signing, and provider adapters for SendGrid, Mailgun, and AWS SES — composable, well-tested, and dependency-light.

go get github.com/KARTIKrocks/goemail

What you get

SMTP SupportTLS / STARTTLS, authentication, and per-message context cancellation
TemplatingGo html/template and text/template for HTML and plain-text bodies
AttachmentsSend files with proper MIME encoding and content types
Retry LogicConfigurable exponential backoff for transient SMTP failures
Rate LimitingBuilt-in token-bucket limiter to avoid overwhelming providers
Connection PoolingReuse SMTP connections for high-throughput sending
Async SendingBackground queue with configurable workers and buffer size
Middleware PipelineComposable logging, metrics, recovery, and lifecycle hooks
Provider AdaptersSendGrid, Mailgun, and AWS SES via HTTP APIs (separate modules)
DKIM SigningRSA-SHA256 / Ed25519 signing per RFC 6376 + 8463 — zero extra deps
WebhooksReceive and normalize delivery events from any provider
Pluggable LoggerBring your own logger — slog, zap, logrus, zerolog, anything
Mock SenderDrop-in test double with assertions on sent messages
Header SafetyAutomatic header-injection protection and address validation

Two layers: Sender and Mailer

goemail is built around a single Sender interface. Concrete senders include NewSMTPSender, NewMockSender, and provider adapters (sendgrid.New, mailgun.New, ses.New). A Mailer wraps any sender with helpers for plain-text, HTML, templates, and batch sending.

Middleware (logging, metrics, hooks, recovery) is applied to senders via email.Chain, so you can compose any sender with any middleware without touching the Mailer.

Where to go next

  • Getting Started — install and send your first email
  • Mailer — the high-level convenience type
  • SMTP — configure the built-in SMTP sender
  • API Reference — full generated godoc on pkg.go.dev

Documentation layout

These guides explain concepts, patterns, and configuration. For exact type signatures, method sets, and struct fields, use pkg.go.dev — it is generated from the source and is always authoritative.

Requirements

Go 1.22 or later. The core module has no third-party dependencies beyond golang.org/x/sync and golang.org/x/time.