Framework Integration

Go + Unosend

Send transactional emails from your Go application using Unosend. Simple HTTP client integration with the Unosend REST API. Perfect for high-performance microservices.

Features

Everything you need to send emails from Go

Simple HTTP client integration

Goroutine-safe

Minimal dependencies

Context and timeout support

Structured error handling

Quick Start

Get up and running in minutes with this code example

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
}

Setup Guide

Follow these steps to integrate Unosend with Go

1

Set UNOSEND_API_KEY environment variable

2

Create an email package with send function

3

Use net/http to make POST requests to the API

4

Add context support for timeout handling

5

Call SendEmail from your handlers or services

Why Use Unosend with Go?

Zero external dependencies

Goroutine-safe for concurrent sending

Low memory footprint

Perfect for microservices architecture

Ready to integrate?

Start sending emails from Go in under 5 minutes. Free tier includes 5,000 emails/month.