smtpapi

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2018 License: MIT Imports: 4 Imported by: 0

README

SendGrid Logo

BuildStatus MIT licensed Email Notifications Badge Twitter Follow GitHub contributors Go Report Card GoDoc

This is a simple library to simplify the process of using SendGrid's X-SMTPAPI with the Go programming language

Table of Contents

Announcements

All updates to this library is documented in our CHANGELOG.

Installation

Prerequisites

  • Go version 1.6
  • The SendGrid service, starting at the free level

Install Package

go get github.com/sendgrid/smtpapi-go

Setup Environment Variables

Environment Variable

Update the development environment with your SENDGRID_API_KEY, for example:

echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

Quick Start

package main

import (
  "github.com/sendgrid/smtpapi-go"
  "fmt"
)

func main() {
  header := smtpapi.NewSMTPAPIHeader()
  header.AddTo("test@example.com")
  fmt.Println(header.JSONString())
}

Usage

Roadmap

If you are interested in the future direction of this project, please take a look at our milestones. We would love to hear your feedback.

How to Contribute

We encourage contribution to our libraries, please see our CONTRIBUTING guide for details.

Quick links:

About

smtpapi-go is guided and supported by the SendGrid Developer Experience Team.

smtpapi-go is maintained and funded by SendGrid, Inc. The names and logos for smtpapi-go are trademarks of SendGrid, Inc.

License

The MIT License (MIT)

Documentation

Index

Constants

View Source
const Version = "0.4.2"

Version represents the current version of the smtpapi-go library

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Settings map[string]interface{} `json:"settings,omitempty"`
}

Filter represents an App/Filter and its settings

type SMTPAPIHeader

type SMTPAPIHeader struct {
	To          []string               `json:"to,omitempty"`
	Sub         map[string][]string    `json:"sub,omitempty"`
	Section     map[string]string      `json:"section,omitempty"`
	Category    []string               `json:"category,omitempty"`
	UniqueArgs  map[string]string      `json:"unique_args,omitempty"`
	Filters     map[string]Filter      `json:"filters,omitempty"`
	ASMGroupID  int                    `json:"asm_group_id,omitempty"`
	ASMGroups   []int                  `json:"asm_groups_to_display,omitempty"`
	SendAt      int64                  `json:"send_at,omitempty"`
	SendEachAt  []int64                `json:"send_each_at,omitempty"`
	IpPool      string                 `json:"ip_pool,omitempty"`
	BatchID     string                 `json:"batch_id,omitempty"`
	DynamicData map[string]interface{} `json:"dynamic_template_data,omitempty"`
}

SMTPAPIHeader will be used to set up X-SMTPAPI params

func NewSMTPAPIHeader

func NewSMTPAPIHeader() *SMTPAPIHeader

NewSMTPAPIHeader creates a new header struct

func (*SMTPAPIHeader) AddASMGroupToDisplay added in v0.5.0

func (h *SMTPAPIHeader) AddASMGroupToDisplay(groupID int)

AddASMGroupToDisplay adds a new ASM group ID to be displayed

func (*SMTPAPIHeader) AddASMGroupsToDisplay added in v0.5.0

func (h *SMTPAPIHeader) AddASMGroupsToDisplay(groupIDs []int)

AddASMGroupsToDisplay adds multiple ASM group IDs to be displayed

func (*SMTPAPIHeader) AddCategories

func (h *SMTPAPIHeader) AddCategories(categories []string)

AddCategories adds multiple categories to the Category header

func (*SMTPAPIHeader) AddCategory

func (h *SMTPAPIHeader) AddCategory(category string)

AddCategory adds a new category to the Category header

func (*SMTPAPIHeader) AddFilter

func (h *SMTPAPIHeader) AddFilter(filter, setting string, value interface{})

AddFilter will set the specific setting for a filter

func (*SMTPAPIHeader) AddSection

func (h *SMTPAPIHeader) AddSection(section, value string)

AddSection sets the value for a specific section

func (*SMTPAPIHeader) AddSendEachAt

func (h *SMTPAPIHeader) AddSendEachAt(sendEachAt int64)

AddSendEachAt takes in a timestamp and pushes it into a list Must match length of To emails

func (*SMTPAPIHeader) AddSubstitution

func (h *SMTPAPIHeader) AddSubstitution(key, sub string)

AddSubstitution adds a new substitution to a specific key

func (*SMTPAPIHeader) AddSubstitutions

func (h *SMTPAPIHeader) AddSubstitutions(key string, subs []string)

AddSubstitutions adds a multiple substitutions to a specific key

func (*SMTPAPIHeader) AddTo

func (h *SMTPAPIHeader) AddTo(email string)

AddTo appends a single email to the To header

func (*SMTPAPIHeader) AddTos

func (h *SMTPAPIHeader) AddTos(emails []string)

AddTos appends multiple emails to the To header

func (*SMTPAPIHeader) AddUniqueArg

func (h *SMTPAPIHeader) AddUniqueArg(arg, value string)

AddUniqueArg will set the value of a specific argument

func (*SMTPAPIHeader) JSONString

func (h *SMTPAPIHeader) JSONString() (string, error)

JSONString returns the representation of the Header

func (*SMTPAPIHeader) Load

func (h *SMTPAPIHeader) Load(b []byte) error

Load allows you to load a pre-formed x-smtpapi header

func (*SMTPAPIHeader) SetASMGroupID

func (h *SMTPAPIHeader) SetASMGroupID(groupID int)

SetASMGroupID will set the value of the ASMGroupID field

func (*SMTPAPIHeader) SetASMGroupsToDisplay added in v0.5.0

func (h *SMTPAPIHeader) SetASMGroupsToDisplay(groups []int)

SetASMGroupsToDisplay will set the value of the ASMGroups field

func (*SMTPAPIHeader) SetCategories

func (h *SMTPAPIHeader) SetCategories(categories []string)

SetCategories will set the value of the Categories field

func (*SMTPAPIHeader) SetFilter

func (h *SMTPAPIHeader) SetFilter(filter string, value *Filter)

SetFilter takes in a Filter struct with predetermined settings and sets it for such Filter key

func (*SMTPAPIHeader) SetIpPool

func (h *SMTPAPIHeader) SetIpPool(ipPool string)

SetIpPool takes a strings and sets the IpPool field

func (*SMTPAPIHeader) SetSections

func (h *SMTPAPIHeader) SetSections(sections map[string]string)

SetSections sets the value for the Section header

func (*SMTPAPIHeader) SetSendAt

func (h *SMTPAPIHeader) SetSendAt(sendAt int64)

SetSendAt takes in a timestamp which determines when the email will be sent

func (*SMTPAPIHeader) SetSendEachAt

func (h *SMTPAPIHeader) SetSendEachAt(sendEachAt []int64)

SetSendEachAt takes an array of timestamps. Must match length of To emails

func (*SMTPAPIHeader) SetSubstitutions

func (h *SMTPAPIHeader) SetSubstitutions(sub map[string][]string)

SetSubstitutions sets the value of the substitutions on the Sub header

func (*SMTPAPIHeader) SetTos

func (h *SMTPAPIHeader) SetTos(emails []string)

SetTos sets the value of the To header

func (*SMTPAPIHeader) SetUniqueArgs

func (h *SMTPAPIHeader) SetUniqueArgs(args map[string]string)

SetUniqueArgs will set the value of the Unique_args header

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL