Simplifyd Cloud

Go Quickstart

Send your first email with the Smail Go SDK.

1. Install the SDK

go get github.com/smail/smail-go

2. Set your API key

Create an API key in the Smail dashboard and export it as an environment variable:

export SMAIL_API_KEY=sk_live_...

3. Send your first email

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	smail "github.com/smail/smail-go"
)

func main() {
	client := smail.NewClient(os.Getenv("SMAIL_API_KEY"))

	email, err := client.Emails.Send(context.Background(), smail.SendEmailRequest{
		From:    "you@yourdomain.com",
		To:      []string{"recipient@example.com"},
		Subject: "Hello from Smail",
		HTML:    "<p>Your first email sent with Smail.</p>",
		Text:    "Your first email sent with Smail.",
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Sent email ID:", email.ID)
	fmt.Println("Status:", email.Status)
}

The From address must belong to a verified domain on your account.

Next steps