Send email with Go

net/smtp is a faithful implementation of a 1982 protocol. Your Go service deserves one stdlib http.Post instead.

Verified By Kam Low, Co-founder · Updated

net/smtp is 1982

Go's net/smtp does exactly what the RFC says and nothing more: no HTML helpers, no auth beyond PLAIN and CRAM-MD5, and the package is frozen by design. The Go team themselves point users elsewhere.

Elsewhere is one stdlib HTTP call.

One POST, and the send is handled

GoPOST /v1/my/messages
body := `{"from":"[email protected]","to":"[email protected]",
  "subject":"Welcome","html":"<p>You're in.</p>"}`

req, _ := http.NewRequest("POST",
  "https://api.nitrosend.com/v1/my/messages",
  strings.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("NITROSEND_API_KEY"))
http.DefaultClient.Do(req)

No third-party module, no SMTP dialer, no TLS negotiation to reason about. The response carries the message ID; your webhook carries the rest.

And the infrastructure behind that POST is sized like a systems engineer would want: we run on a million-a-day sending limit as a baseline, with five million a day available on request. Your Goroutines will not be the bottleneck, and neither will we.

The API design philosophy is fail-closed, which Go engineers will appreciate. We once found a misplaced scheduled_at field being silently dropped, which meant an immediate send instead of a scheduled one: a 24,000-email misfire waiting to happen. Now a wrong-shaped field fails closed with a 422 pointing at the correct one. Silent coercion is how footguns ship. The rule is a hardcoded invariant in the codebase now: audience resolution fails closed, never open.

The API key in that snippet is a server-side credential with full account access. Keep it in the environment on a backend, the way the snippet reads it, and never in anything that ships to a browser or a binary you distribute.

Full parameters, responses, and error codes live in the REST API docs and the API reference.

Python Node.js PHP Go Rust +5
send.py requests ยท stdlib-adjacent
import requests

requests.post(
  "https://api.nitrosend.com/v1/messages",
  headers={"Authorization": f"Bearer {KEY}"},
  json={"to": to, "subject": subj,
        "html": body})
202 ACCEPTED
{ "id": "msg_9f2c",
  "status": "accepted" }

And the part no library gives you

The same account exposes an MCP server, so the agent writing your code can also run your email. Point Claude, Cursor, or Codex at api.nitrosend.com/mcp and it composes, previews, and stages sends, with a human approving every one. The API is for your code. The MCP is for your agent. One platform either way.

Every send comes back with a message ID, and delivery events follow on your webhook: delivered, opened, bounced. No dashboard required to know what happened. If you are staying on SMTP, how to set up SMTP is the setup to follow, and SPF, DKIM and DMARC authentication is what stops those sends landing in spam.

Go deeper

None of the Go idioms above are really the point. A hand-written Goroutine hitting api.nitrosend.com is one option, and describing the send to an agent is the faster one: point Claude, Cursor, or Codex at api.nitrosend.com/mcp and it composes and sends on the same account, no struct to define and no endpoint to remember.

Guides

FAQ

How do I send email from Go?

One http.NewRequest POST to the email API with a JSON body and bearer token. Standard library only, message ID back, delivery events on your webhook.

Why not net/smtp?

The package is frozen, minimal by design, and leaves you assembling MIME and managing TLS and auth yourself. An HTTP API removes all of it and adds deliverability and tracking.

First send in thirty seconds.

Unlimited contacts. Choose your sending volume.

Campaigns, flows and transactional email on every plan. See current prices, included allowances and prepaid services.

Compare plans → · Pricing for agents