[Go SDK]
Gin
High-throughput Gin handlers that send email via the Go SDK with context-aware requests.
1
Install the Go package
bash
go get github.com/reloop-labs/reloop-email2
Send email from Gin
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}3
GitHub, examples, and API reference
4
Need more help?
- Need help? Contact Support.
- Chat with Reloop developers on Discord.
- Check out our changelog.
- Questions? Contact Sales.
- LLM? Read llms.txt.
Send with Gin.
Get an API key and ship transactional email from Gin using the official Go SDK.