Send transactional emails from your Go application using Unosend. Simple HTTP client integration with the Unosend REST API. Perfect for high-performance microservices.
Everything you need to send emails from Go
Simple HTTP client integration
Goroutine-safe
Minimal dependencies
Context and timeout support
Structured error handling
Get up and running in minutes with this code example
package email
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
type EmailRequest struct {
From string `json:"from"`
To string `json:"to"`
Subject string `json:"subject"`
HTML string `json:"html"`
}
func SendEmail(to, subject, html string) error {
payload := EmailRequest{
From: "hello@yourdomain.com",
To: to,
Subject: subject,
HTML: html,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.unosend.co/v1/emails", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("UNOSEND_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return fmt.Errorf("email send failed: %w", err)
}
defer resp.Body.Close()
return nil
}Follow these steps to integrate Unosend with Go
Set UNOSEND_API_KEY environment variable
Create an email package with send function
Use net/http to make POST requests to the API
Add context support for timeout handling
Call SendEmail from your handlers or services
Zero external dependencies
Goroutine-safe for concurrent sending
Low memory footprint
Perfect for microservices architecture
More framework integrations you might like
Send transactional emails from your Next.js application using Unosend. Works with App Router, API routes, and Server Actions.
Build beautiful email templates with React components and send them with Unosend. Use JSX to create responsive HTML emails.
Send emails from Node.js with our official SDK. Support for Express, Fastify, NestJS, and any Node.js application.
Start sending emails from Go in under 5 minutes. Free tier includes 5,000 emails/month.