sendpulse

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 9 Imported by: 0

README

go-sendpulse

Golang client for sendpulse api. Currently you can only send emails with it.

This library use golang.org/x/oauth2/clientcredentials for sendpulse's oauth2 endpoint.

Usage example

package main

import (
	"log"

	sp "github.com/ont/go-sendpulse"
)

func main() {
	s := sp.New("... client-id ...", "... client-secret ...")

	email, err := sp.NewEmail(
		sp.Address{"from me", "sender@some.com"},
		sp.Address{"to this person", "person@test.com"},
		"test subject",
		"<b>test</b> html",
		"test text",
	)
	log.Println(err)

	err = s.SMTP.Send(email)
	log.Println(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type Email

type Email struct {
	EmailFields
}

func NewEmail

func NewEmail(from Address, to interface{}, subject, html, text string) (*Email, error)

func (*Email) MarshalJSON

func (e *Email) MarshalJSON() ([]byte, error)

type EmailFields

type EmailFields struct {
	Html    string    `json:"html"`
	Text    string    `json:"text"`
	Subject string    `json:"subject"`
	From    Address   `json:"from"`
	To      []Address `json:"to"`
}

type Sendpulse

type Sendpulse struct {
	SMTP *apiSmtp
	// contains filtered or unexported fields
}

func New

func New(clientId, clientSecret string, timeout time.Duration, debug bool) *Sendpulse

Jump to

Keyboard shortcuts

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