Go
Introduction
Go
Introduction
Learn how to send your first email using the Resend Go SDK.
Prerequisites
To get the most out of this guide, you’ll need to:
1. Install
Get the Resend Go SDK.
go get github.com/resendlabs/resend-go
2. Send email using HTML
The easiest way to send an email is by using the html
parameter.
main.go
package main
import "github.com/resendlabs/resend-go"
func main() {
apiKey = "re_123"
client := resend.NewClient(apiKey)
params := &resend.SendEmailRequest{
From: "me@exemple.com",
To: []string{"to@mail.com"},
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)
}
3. Try it yourself
Golang Examples
See the full source code.