mailrail

package module
v0.0.0-...-fe629ad Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2016 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Package mailrail reads mail-merge jobs from a persistent queue and sends them via Amazon SES.

Documentation

Documentation

Overview

Package mailrail reads mail-merge jobs from a persistent queue and sends them via Amazon SES.

Each job contains template for the text and/or HTML versions of an email, as well as a list of recipients with associated per-recipient data to be merged into the templates. See the `Spec` type.

Mailrail backs off in response to SES's backpressure signals in order to avoid exceeding the SES sending rate limits.

Index

Constants

This section is empty.

Variables

View Source
var DoNotMangle = Mangler{ShouldSend: true, Mangle: identityAddr, SesService: nil}

Mangler that does not interfere with email sending.

View Source
var DoNotSend = Mangler{ShouldSend: false, Mangle: identityAddr, SesService: nil}

Mangler that prevents emails from being sent.

View Source
var SendToSimulator = Mangler{ShouldSend: true, Mangle: alwaysAddr("success@simulator.amazonses.com"), SesService: nil}

Mangler that causes all emails to be sent to the SES simulator.

Functions

func Process

func Process(queueDir string, mangler Mangler)

Process jobs until there are no more jobs, then stop.

func ProcessForever

func ProcessForever(queueDir string, mangler Mangler)

Wait forever for new jobs and process them.

func ProcessOne

func ProcessOne(queueDir string, mangler Mangler)

Process a single job.

Types

type Mangler

type Mangler struct {
	ShouldSend bool
	Mangle     func(addr string) string
	SesService sesService
}

Manglers allow for stubbing behavior so the system can be tested without sending emails to the actual recipeints. There are some predefined manglers (`DoNotMangle`, `DoNotSend`, `SendToSimulator`) and some predefined functions that return manglers (`SendToMe`, `UseMockSesService`). You can also make your own.

func SendToMe

func SendToMe(addr string) Mangler

Returns a mangler that casues all emails to be sent to a particular address.

func UseMockSesService

func UseMockSesService(ses sesService) Mangler

Returns a mangler that uses a mock SES service.

type Recipient

type Recipient struct {
	Name     string            `json:"name"`
	Addr     string            `json:"addr"`
	FromName string            `json:"from_name"`
	FromAddr string            `json:"from_addr"`
	Subject  string            `json:"subject"`
	Context  map[string]string `json:"context"`
}

type Spec

type Spec struct {
	FromName   string `json:"from_name"`
	FromAddr   string `json:"from_addr"`
	Subject    string `json:"subject"`
	Html       string `json:"html"`
	Text       string `json:"text"`
	Recipients []Recipient
}

Directories

Path Synopsis
cmd
mailrail-submit
The submit command adds a spec to a pqueue.
The submit command adds a spec to a pqueue.
mailrail-worker
Worker that processes mailrail jobs from a pqueue.
Worker that processes mailrail jobs from a pqueue.

Jump to

Keyboard shortcuts

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