• Stars
    star
    62
  • Rank 490,914 (Top 10 %)
  • Language
    Go
  • License
    Other
  • Created about 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SparkPost client library for the Go Programming Language

image

Sign up for a SparkPost account and visit our Developer Hub for even more content.

SparkPost Go API client

Build Status

Code Coverage

Go Doc

The official Go package for using the SparkPost API.

Installation

Install from GitHub using go get:

$ go get github.com/SparkPost/gosparkpost

Get a key

Go to API & SMTP in the SparkPost app and create an API key. We recommend using the SPARKPOST_API_KEY environment variable. The example code below shows how to set this up.

Send a message

Here at SparkPost, our "send some messages" api is called the transmissions API - let's use it to send a friendly test message:

package main

import (
  "log"
  "os"

  sp "github.com/SparkPost/gosparkpost"
)

func main() {
  // Get our API key from the environment; configure.
  apiKey := os.Getenv("SPARKPOST_API_KEY")
  cfg := &sp.Config{
    BaseUrl:    "https://api.sparkpost.com",
    ApiKey:     apiKey,
    ApiVersion: 1,
  }
  var client sp.Client
  err := client.Init(cfg)
  if err != nil {
    log.Fatalf("SparkPost client init failed: %s\n", err)
  }

  // Create a Transmission using an inline Recipient List
  // and inline email Content.
  tx := &sp.Transmission{
    Recipients: []string{"[email protected]"},
    Content: sp.Content{
      HTML:    "<p>Hello world</p>",
      From:    "[email protected]",
      Subject: "Hello from gosparkpost",
    },
  }
  id, _, err := client.Send(tx)
  if err != nil {
    log.Fatal(err)
  }

  // The second value returned from Send
  // has more info about the HTTP response, in case
  // you'd like to see more than the Transmission id.
  log.Printf("Transmission sent with id [%s]\n", id)
}

Documentation

Contribute

TL;DR:

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  2. Fork the repository.
  3. Go get the original code - go get https://github.com/SparkPost/gosparkpost
  4. Add your fork as a remote - git remote add fork http://github.com/YOURID/gosparkpost
  5. Make your changes in a branch on your fork
  6. Write a test which shows that the bug was fixed or that the feature works as expected.
  7. Push your changes - git push fork HEAD
  8. Send a pull request. Make sure to add yourself to AUTHORS.

More on the contribution process

More Repositories

1

heml

HEML is an open source markup language for building responsive email.
JavaScript
4,329
star
2

php-sparkpost

SparkPost client library for PHP
PHP
195
star
3

node-sparkpost

SparkPost client library for Node.js
JavaScript
180
star
4

matchbox

🔥 A react UI component library
TypeScript
109
star
5

python-sparkpost

SparkPost client library for Python
Python
92
star
6

elixir-sparkpost

SparkPost client library for Elixir https://developers.sparkpost.com
Elixir
44
star
7

java-sparkpost

SparkPost client library for Java
Java
39
star
8

nodemailer-sparkpost-transport

Sparkpost transport for Nodemailer
JavaScript
26
star
9

wordpress-sparkpost

WordPress plugin to use SparkPost email
PHP
20
star
10

pizza-bot

Learn how to order 🍕 from Slack
JavaScript
20
star
11

developers.sparkpost.com

SparkPost Developer Site and Documentation
API Blueprint
18
star
12

heml.io

HEML website
JavaScript
17
star
13

code-snippets

A repository with helpful programming resources for SparkPost developers.
JavaScript
17
star
14

bouncy-sink

A PMTA-based sink application that does opens, clicks, bounces, OOBs and FBLs
Python
16
star
15

github-alerts-to-slack

Sends a report of Github security alerts to Slack
JavaScript
11
star
16

gitplus

Generic tools and instructions for making it easier to work with git as a team.
Shell
11
star
17

support-docs

SparkPost support articles
TypeScript
11
star
18

auditmated

Automated npm auditing
Shell
10
star
19

gimli

Gimli is a crash tracing/analysis framework. It is available under a 3-clause BSD style license.
C
9
star
20

sp-forwarding-service

A small Heroku service that will consume inbound message webhook POSTs and forward them through SparkPost.
JavaScript
8
star
21

raffles

Email-driven raffle service
JavaScript
8
star
22

slack-etiquette

Kind of like Emily Post, but for Slack
7
star
23

umem

Portable umem Slab allocator
C
7
star
24

sparkpost-cli

A CLI to perform various tasks using the SparkPost API
Go
6
star
25

mandrill-sparkpost-templates

Translate Mandrill Handlebars templates into SparkPost templates
JavaScript
6
star
26

eriksen

A model marshaling library for dual-write/single-read data migration
JavaScript
6
star
27

template-library

A collection of example email templates for use with SparkPost
HTML
5
star
28

node-sparkpost-cli

A command-line interface to SparkPost.
JavaScript
5
star
29

elixir-webhook-sample

A report of recipient OS usage from SparkPost click events and the User-Agent header, with Elixir and Phoenix
Elixir
4
star
30

sparkpost-csv2tx

BASH script to import a CSV and convert it to a Recipient List and delivery a Transmission with SparkPost.
Shell
3
star
31

community-bot

A bot for the SparkPost community Slack team
JavaScript
3
star
32

event-data

self-hosted message events
JavaScript
3
star
33

azure-csharp-webhook-sample

A .NET Core sample that receives and processes SparkPost webhook events
C#
3
star
34

httpdump

Store HTTP request data, and provide a simple framework for post-processing in parallel.
Go
3
star
35

momentum-documentation

Repository for Momentum Documentation
JavaScript
3
star
36

csharp

Community-maintained C# SparkPost client library
3
star
37

eslint-config-sparkpost

ESLint configuration for Javascript based SparkPost projects
JavaScript
3
star
38

mbot

our hubot
CoffeeScript
2
star
39

sparkyEvents-Gmail-bounces-Dec2020

Python
2
star
40

postman-collection

A Postman collection for SparkPost
2
star
41

campaign-sparkpost

✨ SparkPost email provider for Campaign
JavaScript
2
star
42

momentum-scriptlets

Lua
2
star
43

msys-jlog-tools

Miscellaneous tools for JLog (journalled log) files
Perl
2
star
44

momentum_sample_policy

Example policy for Momentum
Perl
2
star
45

sparkybluemix-poc

An example of using Sparkpost.com for sending email via IBM Bluemix PaaS
JavaScript
2
star
46

AzureFunctionsWebhooksDemo

Consume webhooks with Azure Functions
C#
1
star
47

design.sparkpost.com

SparkPost Design Documentation Site
HTML
1
star
48

bower-sinon

Bower repo for Sinon.js
JavaScript
1
star
49

styles

CSS
1
star
50

lua-policies

Example business policies, implemented in the Momentum Business Policy Framework
Lua
1
star
51

relaymsgdb

Persist, parse, and present subject lines, organized by sender localpart
Go
1
star
52

node-red-contrib-sparkpost

Letting SparkPost go with the flow in node-red
JavaScript
1
star
53

AnalyticsTakeHomeTest

A place to showcase your abilities
1
star
54

codeland

1
star
55

webhook-report-sample

Build a report of recipient OS usage from SparkPost click events and the User-Agent header
PHP
1
star
56

events-search-example

Example code for integrating with SparkPost Events Search API
JavaScript
1
star
57

ux-github-slack-alerts

JavaScript
1
star
58

puppet-openresty

Ruby
1
star
59

appengine-flexible-python-sample

Sample app using Python, Flask and SparkPost in the Google App Engine flexible environment
Python
1
star