go-mail

A modern, idiomatic Go library for composing and sending email over SMTP with a minimal dependency footprint.

Library
Go
vv0.8.1
1,473stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
85/100Excellent
Development Activity92
Maintenance96
Community56
Maturity56
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture82
Code Quality88
Innovation78
Learning Curve80

go-mail is a comprehensive, idiomatic Go library for composing and delivering email. It combines mail message construction, MIME encoding, DKIM and S/MIME signing, and SMTP delivery into a single package built almost entirely on the Go standard library and its official extended packages, giving Go programs the capabilities of a full mail user agent without pulling in a heavy dependency tree.

Under the hood it forks and extends Go’s net/smtp package with additional authentication mechanisms (including NTLM and SCRAM-SHA-256-PLUS), concurrency-safe connection reuse, and a pluggable error registry for non-RFC-conformant servers. It supports attachments and inline embeds from files, io.Reader, or embed.FS, HTML/text templating, middleware for altering messages before send, and EML import/export for interoperability with other mail tools.

What You Get

  • A functional-options Client/Msg API for building and sending mail without constructor boilerplate
  • Support for 7 SMTP authentication mechanisms including OAuth2 (XOAUTH2), NTLM, and SCRAM-SHA-256-PLUS
  • Built-in DKIM and S/MIME (RSA and ECDSA) message signing
  • Attachment and inline-embed support from the filesystem, io.Reader, embed.FS, or fs.FS
  • HTML and text templating support via Go’s html/template and text/template
  • EML file import/export for interoperability with mail user agents

Common Use Cases

  • Sending transactional email (password resets, notifications, receipts) from a Go backend
  • Delivering DKIM- and S/MIME-signed mail for organizations with strict deliverability/compliance requirements
  • Composing and sending templated HTML emails with inline images and attachments
  • Building internal tooling or CLIs that need to send mail via SMTP, sendmail, or a UNIX domain socket
  • Testing mail delivery code with output-to-file (.eml) support instead of a live SMTP server

Under The Hood

Architecture The root mail package is built around three primary types — Client (client.go, functional-options constructor NewClient(host, opts...)), Msg (msg.go, functional-options NewMsg(opts...), holding headers, parts, and attachments), and MsgWriter (msgwriter.go, an RFC 2047/2045-aware multipart serializer with explicit header/body line-length constants). Delivery flows Msg → MsgWriter → the vendored smtp package (a fork of Go’s net/smtp), with cross-cutting concerns pulled into internal packages: internal/dkim for DKIM signing, internal/pkcs7 plus root smime.go for S/MIME signing, internal/ntlm for NTLM auth, and internal/helper for shared utilities. A Middleware interface lets third-party code transform a Msg before send, and quicksend.go’s QuickSend() composes Client and Msg into a one-shot helper for simple cases. The layering is clean and modular; the one architecturally load-bearing decision is forking net/smtp rather than wrapping it, which means any future stdlib SMTP changes must be re-ported by hand.

Tech Stack go-mail targets Go 1.25 and depends on only two modules beyond the standard library: golang.org/x/crypto (S/MIME and DKIM cryptography) and golang.org/x/text (charset/encoding handling) — an intentionally minimal footprint built on crypto/tls, mime/multipart, net/textproto, and context. It ships a Nix flake (flake.nix/flake.lock) alongside standard go build/go test tooling, with GitHub Actions CI, CodeQL static analysis, and OpenSSF Scorecard checks, plus Codecov coverage reporting and REUSE/SPDX license-header compliance across the source tree.

Code Quality The repository carries 19 _test.go files sitting alongside their corresponding implementation files (auth_test.go, client_test.go, dkim_test.go, msg_test.go, smtp/smtp_test.go, and more) using Go’s standard testing package with table-driven patterns, and codecov.yml shows coverage is tracked and gated in CI. Errors are explicit and typed rather than swallowed — senderror.go defines custom delivery error types, and functions consistently wrap errors with %w for traceability. Naming follows idiomatic Go conventions (With* functional options, Set*/Get* accessors), and every exported symbol carries dense, consistently formatted GoDoc comments describing parameters and return values. CodeQL and OpenSSF Scorecard both run on every change in addition to the test suite.

What Makes It Unique Most Go SMTP libraries either wrap the unmodified standard-library net/smtp package (missing OAuth2, NTLM, and SCRAM support) or shell out to an external sendmail binary. go-mail instead forks and extends net/smtp directly, adding concurrency-safe connection reuse, a pluggable error registry for non-RFC-conformant servers, and seven distinct SMTP authentication mechanisms — while also layering on DKIM signing, S/MIME (RSA and ECDSA) signing, DSN/MDN request headers, and EML import/export, all on top of the standard library plus two extended packages rather than a C library binding. This is deep, deliberate engineering investment in a narrow domain rather than a novel architectural paradigm.

Used by 8 apps in this directory

Go
86%
Apache 2.0

Authelia

Security · Authentication

28,742

OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.

View details
91
Repo Health
81
Technical
77
Dependency
Built with
Go86%
TypeScript12%
Updated today
Go
83%
MIT

Gitea

Devops · Developer Tools · Project Management

57,677

Self-hosted DevOps in a single Go binary — Git hosting, GitHub Actions-compatible CI/CD, and 30+ package registries without any SaaS dependency.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
Go83%
Updated today
Go
68%
MIT

Gogs

Developer Tools

47,783

The painless self-hosted Git service that runs on anything from a Raspberry Pi to a $5 cloud droplet, delivering GitHub-like workflows as a single Go binary.

View details
96
Repo Health
79
Technical
72
Dependency
Built with
Go68%
Go Template16%
TypeScript10%
Updated 4 days ago
Go
84%
MIT

Hatchet

AI Development · Developer Tools · Automation

7,812

A Postgres-backed orchestration engine for background tasks, AI agents, and durable workflows that replaces Redis queues and multi-datastore durable execution platforms with a single self-hostable service.

View details
88
Repo Health
83
Technical
68
Dependency
Built with
Go84%
PLpgSQL11%
Updated today
TypeScript
51%
Other

Mattermost

Team Chat · Collaboration · Devops

38,940

Open core, self-hosted team collaboration with chat, AI agents, voice calling, and deep DevOps integrations — all under your control.

View details
96
Repo Health
87
Technical
65
Dependency
Built with
TypeScript51%
Go40%
Updated yesterday
Go
74%
Other

Notifuse

Marketing

2,089

Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.

View details
83
Repo Health
80
Technical
66
Dependency
Built with
Go74%
TypeScript23%
Updated yesterday
Go
54%
AGPL 3.0

Uptrace

Monitoring · Devops

4,274

Unified open-source APM that collects OpenTelemetry traces, metrics, and logs into a single self-hosted platform backed by ClickHouse.

View details
63
Repo Health
70
Technical
66
Dependency
Built with
Go54%
Vue34%
Updated 2 weeks ago
Go
73%
AGPL 3.0

Vikunja

Project Management

5,206

Self-hosted task management with natural-language quick-add, multiple views, and a fully documented REST API — your tasks, your infrastructure, zero lock-in.

View details
86
Repo Health
81
Technical
74
Dependency
Built with
Go73%
TypeScript14%
Vue12%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search