All frameworks

Send Email from Gin

Send emails from Gin HTTP handlers

1

Install the SDK

go get github.com/sendpigeon/sendpigeon-go
2

Set your API key

SENDPIGEON_API_KEY=your_api_key_here

Get your API key from the dashboard.

3

Send your first email

go
package main

import (
	"net/http"
	"os"

	"github.com/gin-gonic/gin"
	"github.com/sendpigeon/sendpigeon-go/sendpigeon"
)

func main() {
	client := sendpigeon.New(os.Getenv("SENDPIGEON_API_KEY"))
	r := gin.Default()

	r.POST("/contact", func(c *gin.Context) {
		var req struct {
			Email string `json:"email"`
			Name  string `json:"name"`
		}
		c.BindJSON(&req)

		client.Send(c.Request.Context(), sendpigeon.SendEmailRequest{
			To:      []string{req.Email},
			From:    "hello@yourdomain.com",
			Subject: "Thanks for reaching out, " + req.Name + "!",
			HTML:    "<h1>We got your message</h1><p>We'll get back to you soon.</p>",
		})

		c.JSON(http.StatusOK, gin.H{"success": true})
	})

	r.Run(":3000")
}

Why use SendPigeon with Gin?

  • Context-aware requests
  • High performance
  • Middleware support
  • 99.9% deliverability with dedicated IPs
  • Real-time analytics and webhook events
🧪

Testing locally? Use our local email server to catch emails without sending real ones.

🎨

Prefer visual editing? Build email templates with our free drag-and-drop builder. Learn more →

Ready to send emails from Gin?

Start free with 3,000 emails/month. No credit card required.

Get Started Free

Other go frameworks