Skip to content
forked from gsamokovarov/sg

Golang library for transactional еmails through SendGrid or SparkPost.

Notifications You must be signed in to change notification settings

webedx-spark/sg

 
 

Repository files navigation

SG

A simple library for sending transactional mails through SendGrid or SparkPost.

Usage

The simplest way to send a mail is through sg.Send which uses a global client:

package main

import "github.com/gsamokovarov/sg"

func main() {
	// If you have your key in the SG_API_KEY environment variable, you may
	// skip this step.
	sg.Setup(sg.NewSendGridClient("API_KEY"))

	sg.Send(&sg.Mail{
		TemplateId:    "c2723c5e-b693-4086-968f-bd9057cc6ae4",
		From:          "[email protected]",
		To:            "[email protected]",
		Substitutions: sg.H{"SUB": "value"},
	})
}

The global client is using SendGrid, by default. If you don't want to use a global client, you can build your own.

package main

import "github.com/gsamokovarov/sg"

func main() {
	// If you have your key in the SG_API_KEY environment variable, you may
	// skip this step.
	client := sg.NewSparkPostClient("API_KEY")

	client.Send(&sg.Mail{
		TemplateId:    "c2723c5e-b693-4086-968f-bd9057cc6ae4",
		From:          "[email protected]",
		To:            "[email protected]",
		Substitutions: sg.H{"SUB": "value"},
	})
}

About

Golang library for transactional еmails through SendGrid or SparkPost.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.3%
  • Makefile 0.7%