[Go SDK]
Gin
High-throughput Gin handlers that send email via the Go SDK with context-aware requests.
Step 1
Install the package
Add the official Go client to your Gin project.
bash
go get github.com/reloop-labs/reloop-emailStep 2
Set your API key
Create a free Reloop account, copy your API key, and add it to your Gin environment.
Get an API key free โbash
RELOOP_API_KEY="re_xxxxxxxx"Step 3
Send email from Gin
Use this Gin snippet to send your first message. Works with Handlers ยท Middleware.
send_email.go
1package main2
3import (4 "net/http"5 "os"6
7 "github.com/gin-gonic/gin"8 reloopemail "github.com/reloop-labs/reloop-email"9)10
11func main() {12 reloop, _ := reloopemail.NewClient(reloopemail.ClientOptions{13 APIKey: os.Getenv("RELOOP_API_KEY"),14 })15
16 r := gin.Default()17 r.POST("/send", func(c *gin.Context) {18 email, err := reloop.Emails().Send(c.Request.Context(), &reloopemail.SendEmailParams{19 From: "Acme <onboarding@yourdomain.com>",20 To: []string{c.PostForm("to")},21 Subject: "Hello from Gin",22 Html: "<strong>It works!</strong>",23 })24 if err != nil {25 c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})26 return27 }28 c.JSON(http.StatusOK, gin.H{"id": email.ID})29 })30
31 r.Run(":8080")32}Next steps
Examples, docs, and API reference
Go deeper with working code and the full API for Go.
Other frameworks
Same API, framework-specific examples.
Send with Gin.
Get an API key and ship transactional email from Gin using the official Go SDK.