Send email
with Go

Send with net/http, or with net/smtp from the standard library. No modules to add.

POST/v1/send
200 OK
To
ana@acme.com
From
Acme <hello@acme.com>
Subject
Reset your password

Reset your password

To ana@acme.com

  1. Sent09:41:02
  2. Delivered09:41:03
  3. Opened09:42:18

Before you send

  1. Create a project

    Sign up for free and copy your secret key from the project settings.

  2. Verify your domain

    Add the DNS records Plunk shows you. It checks them and tells you when you can send.

  3. Send

    Use the API or your framework’s mailer, below. Every email shows up in the dashboard.

Send with the API

One POST request with the standard library.

send.go
payload, err := json.Marshal(map[string]string{
	"to":      "ana@acme.com",
	"subject": "Welcome to Acme",
	"body":    "<p>Thanks for signing up.</p>",
})
if err != nil {
	return err
}

req, err := http.NewRequest("POST", "https://send-api.akmarketingseo.com/v1/send", bytes.NewReader(payload))
if err != nil {
	return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("PLUNK_SECRET_KEY"))

resp, err := http.DefaultClient.Do(req)
if err != nil {
	return err
}
defer resp.Body.Close()

if resp.StatusCode >= 300 {
	return fmt.Errorf("plunk returned %d", resp.StatusCode)
}

Send with Go over SMTP

net/smtp upgrades to TLS on port 587 automatically.

send_smtp.go
auth := smtp.PlainAuth("", "plunk", os.Getenv("PLUNK_SECRET_KEY"), "smtp.useplunk.com")

message := []byte("From: Acme <hello@acme.com>\r\n" +
	"To: ana@acme.com\r\n" +
	"Subject: Welcome to Acme\r\n" +
	"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
	"<p>Thanks for signing up.</p>")

err := smtp.SendMail("smtp.useplunk.com:587", auth, "hello@acme.com", []string{"ana@acme.com"}, message)

Frequently asked questions

Send your first email from Go.

Start on the free plan with 1,000 emails a month, no credit card needed. When you need more, every email is $0.001, with unlimited contacts and every feature included.