list

package
v0.0.0-...-cba5d97 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const BounceInterval = 7 * 24 * time.Hour

BounceInterval is used to compute ban times when bouncing.

Variables

This section is empty.

Functions

func NewBot

func NewBot(backend Backend) *bot

NewBot creates a new bot from a backend

func NewBotFactory

func NewBotFactory(backend Backend) botFactory

NewBotFactory creates a bot factory from a bot

func NewList

func NewList(backend Backend, definition Definition) *list

NewList creates a new list from a backend and a definition

func SendMail

func SendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) error

SendMail with InsecureSkipVerify set to true

Types

type Backend

type Backend interface {
	Config() Config
	Lists() ([]Definition, error)
	CreateList(Definition) error
	ModifyList(string, Definition) error
	DeleteList(string) error
	LookupList(string) (*Definition, error)
	ListSubscribe(Definition, string) error
	ListUnsubscribe(Definition, string) error
	ListSetBounce(Definition, string, uint16, time.Time) error
	ListSubscribers(Definition) ([]Subscription, error)
	ListIsSubscribed(Definition, string) (*Subscription, error)
	ListArchive(Definition, *Message) error
}

A Backend can be used to create a bot

type BounceResponse

type BounceResponse struct {
	BounceAddress string
	List          string
	Address       string
}

A BounceResponse represents an incoming mail on the bounce address with a list and an address specified as parameter

type Command

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

A Command represents a command parser

func AddCommand

func AddCommand(app *kingpin.Application, admin bool, userAddress string, botFactory botFactory) *Command

AddCommand adds bot commands to a given kingpin application

func NewCommand

func NewCommand(admin bool, userAddress string, b *bot, w io.Writer) *Command

NewCommand returns a Command application object

func (*Command) Parse

func (c *Command) Parse(params []string) (string, error)

Parse parses a CLI using the given arguments

func (*Command) ParseString

func (c *Command) ParseString(paramsString string) (string, error)

ParseString parses a CLI using the given arguments

type Config

type Config struct {
	CommandAddress string   `ini:"command_address"`
	BouncesAddress string   `ini:"bounces_address"`
	AdminAddresses []string `ini:"admin_addresses"`
	SMTPHostname   string   `ini:"smtp_hostname"`
	SMTPPort       uint64   `ini:"smtp_port"`
	SMTPUsername   string   `ini:"smtp_username"`
	SMTPPassword   string   `ini:"smtp_password"`
	Debug          bool     `ini:"debug"`
}

A Config represents general configuration for a mailing list bot

type Definition

type Definition struct {
	Address         string   `ini:"address"`
	Name            string   `ini:"name"`
	Description     string   `ini:"description"`
	Hidden          bool     `ini:"hidden"`
	Locked          bool     `ini:"locked"`
	SubscribersOnly bool     `ini:"subscribers_only"`
	Posters         []string `ini:"posters,omitempty"`
	Bcc             []string `ini:"bcc,omitempty"`
}

A Definition defines a list definition.

func (Definition) String

func (def Definition) String() string

type Message

type Message struct {
	XOriginalTo     string
	Subject         string
	From            string
	To              string
	Cc              string
	Bcc             string
	Date            string
	Sender          string
	Address         string
	InReplyTo       string
	Precedence      string
	ListID          string
	ListUnsubscribe string
	ListSubscribe   string
	ListArchive     string
	ListOwner       string
	ListHelp        string
	XMailingList    string
	XLoop           string
	MIMEVersion     string
	ContentType     string
	Headers         map[string][]string
	Body            []byte
}

Message represents an e-mail message

func (*Message) FromReader

func (msg *Message) FromReader(stream io.Reader) error

FromReader reads a message from the given io.Reader

func (*Message) Reply

func (msg *Message) Reply() *Message

Reply creates a new message that replies to the given message

func (*Message) ResendAs

func (msg *Message) ResendAs(list *list, commandAddress string) *Message

ResendAs a list prepares a copy of the message to be used for a list forward

func (*Message) Send

func (msg *Message) Send(envelopeSender string, recipients []string, SMTPHostname string, SMTPPort uint64, SMTPUsername string, SMTPPassword string, debug bool) error

Send a Message

func (*Message) SendDebug

func (msg *Message) SendDebug(envelopeSender string, recipients []string) string

SendDebug returns a string describing the message that would be sent, and its recipients

func (*Message) SendVERP

func (msg *Message) SendVERP(envelopeSender string, recipients []string, SMTPHostname string, SMTPPort uint64, SMTPUsername string, SMTPPassword string, debug bool) error

SendVERP sends a Message using an VARP

func (*Message) String

func (msg *Message) String() string

String representing the message

type Subscription

type Subscription struct {
	Address    string
	Bounces    uint16
	LastBounce time.Time
}

Subscription describes a subscription with metadata

Jump to

Keyboard shortcuts

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