Developer guide

Send an email in Go without an SMTP server

Send a DKIM-signed transactional email from Go with net/http — no SMTP server, no external dependency. Here are the steps, with the standard library or curl.

  1. 1

    Add and verify your domain

    Add your sending domain in Spore and publish the DNS records it gives you (DKIM, SPF, DMARC). Spore validates them automatically once propagated.

  2. 2

    Create an API key

    Generate an API key (sk_live_…) and expose it through SPORE_API_KEY. Load it from the environment, never hard-code it.

  3. 3

    Send with net/http

    No external dependency: the standard library is enough. Build the JSON body, add the Bearer header, and POST to /emails.

    go
    package main
    
    import (
    	"bytes"
    	"encoding/json"
    	"fmt"
    	"net/http"
    	"os"
    )
    
    func main() {
    	body, _ := json.Marshal(map[string]any{
    		"from":    "hello@yourdomain.com",
    		"to":      []string{"alex@example.com"},
    		"subject": "Welcome aboard",
    		"html":    "<p>Hi Alex, your account is ready.</p>",
    	})
    
    	req, _ := http.NewRequest("POST", "https://api.sporee.fr/emails", bytes.NewReader(body))
    	req.Header.Set("Authorization", "Bearer "+os.Getenv("SPORE_API_KEY"))
    	req.Header.Set("Content-Type", "application/json")
    
    	res, err := http.DefaultClient.Do(req)
    	if err != nil {
    		panic(err)
    	}
    	defer res.Body.Close()
    	fmt.Println("status:", res.Status)
    }
  4. 4

    Or test quickly with curl

    For a manual test before integrating, the same send is a single curl.

    bash
    curl -X POST https://api.sporee.fr/emails \
      -H "Authorization: Bearer $SPORE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "from": "hello@yourdomain.com",
        "to": ["alex@example.com"],
        "subject": "Welcome aboard",
        "html": "<p>Hi Alex, your account is ready.</p>"
      }'
  5. 5

    Verify delivery

    Query GET /emails/:id for the per-attempt history, or wire up a webhook for email.sent, email.bounced and email.failed events.

Frequently asked questions

Can I send an email in Go without a third-party library?
Yes. With Spore, the standard library's net/http is enough: a JSON POST to /emails with a Bearer header.
Is a Go SDK available?
A generated Go client is in progress (WIP). In the meantime, the direct net/http call is fully functional.
Do I have to manage DKIM and bounces myself?
No. Spore signs with DKIM server-side and handles bounces and suppressions automatically.

Ready to send your first email?