Send emails with Go
Prerequisites
Section titled “Prerequisites”Before you start, you'll need:
- A Resend API key
- A verified domain
Install
Get the Resend Go SDK.
bash go get github.com/resend/resend-go/v4Send email using HTML
The easiest way to send an email is by using the
htmlparameter.main.go package main import ( "fmt" "github.com/resend/resend-go/v4" ) func main() { client := resend.NewClient("re_xxxxxxxxx") params := &resend.SendEmailRequest{ From: "Acme <onboarding@resend.dev>", To: []string{"delivered@resend.dev"}, Html: "<strong>hello world</strong>", Subject: "Hello from Golang", Cc: []string{"cc@example.com"}, Bcc: []string{"bcc@example.com"}, ReplyTo: "replyto@example.com", } sent, err := client.Emails.Send(params) if err != nil { fmt.Println(err.Error()) return } fmt.Println(sent.Id) }
Examples
Section titled “Examples”Basic Send
Basic email sending
Attachments
Send emails with file attachments
Inline Images (CID)
Embed inline images using CID
Templates
Send emails using Resend hosted templates
Scheduling
Schedule emails for future delivery
Prevent Threading
Prevent email threading on Gmail
Audiences
Manage contacts and audiences
Domains
Create and manage sending domains
Inbound Webhooks
Receive and process inbound emails
Double Opt-in
Double opt-in subscription flow
Chi App
Full Chi web framework application
Gin App
Full Gin web framework application