sendcloud

package module
v0.0.0-...-0b4b2c8 Latest Latest
Warning

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

Go to latest
Published: May 16, 2014 License: MIT Imports: 14 Imported by: 2

README

# go-sendcloud

Sendcloud client in Go. API doc http://godoc.org/github.com/riobard/go-sendcloud

Documentation

Overview

Sendcloud client in Go.

Index

Constants

View Source
const (
	API_ENDPOINT = "https://sendcloud.sohu.com/webapi/"
)

Variables

View Source
var (
	ErrMethodNotAllowed = fmt.Errorf("method not allowed")
	ErrBadSignature     = fmt.Errorf("bad signature")
	ErrInvalidTimestamp = fmt.Errorf("invalid timestamp")
	ErrInvalidForm      = fmt.Errorf("invalid form data")
)
View Source
var EMAIL_DOMAIN_RE = regexp.MustCompile(`[^<>]+<?.+@([^<>]+)>?`)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New() *Client

func (*Client) AddDomain

func (c *Client) AddDomain(domain, api_user, api_key string)

add a sending domain with its authentication info

func (*Client) Send

func (c *Client) Send(m Mail) (id string, err error)

func (*Client) SendTemplate

func (c *Client) SendTemplate(templateName string, subject string, from string, fromName string, substitutionVars *Substitution) (err error)

使用WebAPI发送模板 substitutionVars里面的To的长度应该和Sub下每一个value的长度一致

type Event

type Event struct {
	// contains filtered or unexported fields
}

func (*Event) MsgId

func (e *Event) MsgId() string

func (*Event) Name

func (e *Event) Name() string

func (*Event) Rcpt

func (e *Event) Rcpt() string

func (*Event) Reason

func (e *Event) Reason() string

func (*Event) Time

func (e *Event) Time() time.Time

type Mail

type Mail interface {
	From() string // mail-from address
	To() []string
	Cc() []string
	Bcc() []string
	ReplyTo() string // reply-to address
	Subject() string
	Html() string               // HTML mail body
	Headers() map[string]string // extra mail headers
}

type Substitution

type Substitution struct {
	To  []string            `json:"to"`
	Sub map[string][]string `json:"sub"`
}

邮件模板替换参数

func NewSubstitution

func NewSubstitution() *Substitution

返回一个新的替换参数

func (*Substitution) AddSub

func (s *Substitution) AddSub(search, replace string)

在替换参数里面增加一组替换

func (*Substitution) AddTo

func (s *Substitution) AddTo(to string)

在替换参数里面增加一个收件人

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

func NewWebhook

func NewWebhook(key string) *Webhook

func (*Webhook) Handle

func (wh *Webhook) Handle(w http.ResponseWriter, req *http.Request) (evt *Event, err error)

func (*Webhook) Verify

func (wh *Webhook) Verify(timestamp, token, signature string) bool

Jump to

Keyboard shortcuts

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