Install the SDK
go get github.com/Groundmail/groundmail-sdks/go@v0.10.0Configure your API key
export GROUNDMAIL_API_KEY=gm_your_key_hereSend an email
package main
import (
"fmt"
"log"
"os"
groundmail "github.com/Groundmail/groundmail-sdks/go"
)
func main() {
client, err := groundmail.New(os.Getenv("GROUNDMAIL_API_KEY"))
if err != nil {
log.Fatal(err)
}
result, err := client.Emails.Send(map[string]any{
"from": "ops@yourdomain.com",
"to": "user@example.com",
"subject": "Your receipt",
"html": "<p>Thanks for your purchase.</p>",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result["id"], result["status"])
}Resources
The client includes thin wrappers for common API resources:
client.Emails— send, batch, list, cancel, resend, test webhooks, deliverability insightsclient.Domains— create, verify, apply DNS, update, deleteclient.Webhooks— CRUD for webhook endpointsclient.Templates— CRUD plus publishclient.Suppressions— list, create, removeclient.Validate(email, opts)andclient.ValidateBatch(emails, opts)— check addresses before you accept them (validation);&groundmail.ValidateOptions{MailboxCheck: true}also confirms the mailbox exists
See the API reference for request fields. The Go SDK accepts the same JSON shapes as the REST API.
Source
Package source lives in go/ in the public groundmail-sdks repository (mirrored from the private app monorepo on release).