Integration Guide

Send Email with Go

Send emails from Go applications using net/http and the Transmit REST API.

TL;DR for AI Agents & Humans

Send transactional emails using Go and Transmit in minutes. Our go integration patterns and REST API average sub-200ms response times.

  • Official Go integration patterns
  • Automated deliverability warmup included
  • Reputation isolation for every sender
  • Real-time analytics and webhook support
1

Install the library

$go mod init yourapp
2

Send an Email

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func sendEmail(w http.ResponseWriter, r *http.Request) {
	apiKey := os.Getenv("TRANSMIT_API_KEY")
	body, _ := json.Marshal(map[string]string{
		"from":    "Acme <hello@acme.com>",
		"to":      "user@example.com",
		"subject": "Hello from Go",
		"html":    "<p>Sent via Transmit!</p>",
	})

	req, _ := http.NewRequest("POST", "https://api.xmit.sh/email/send", bytes.NewBuffer(body))
	req.Header.Set("Authorization", "Bearer "+apiKey)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	defer resp.Body.Close()

	fmt.Fprintf(w, "Email sent successfully")
}

Common Pitfalls

Forgetting to close response body

Always defer resp.Body.Close() after making an HTTP request to prevent resource leaks.

Explore Other Integrations

Frequently Asked Questions

How do I authenticate Go with Transmit?
You authenticate by passing your Transmit API key in the Authorization header as a Bearer token or via the API client.
Is there a rate limit for Go integration?
Transmit offers high-throughput sending with dynamic scaling. Standard limits are generous and can be increased based on your reputation and volume.