sendme

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

sendme

Mail sender application and more.

TODO

List of planned features:

  1. Check duplicate with hash
  2. Add capability to include attachment
  3. UI e.g. web-based
  4. Load data from database
  5. More friendly logging

Documentation

Index

Constants

View Source
const (
	HtmlFormat  = "HTML"
	PlainFormat = "PLAIN"
)

Html/Text message format

View Source
const (
	ActSend = iota
	ActSendAll
	ActDontSend
	ActAbortSend
	ActContinueError
)

Action to be taken before sending. Options send email(Y/N/Abort)?

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server   *ServerConfig   `json:"server"`
	Delivery *DeliveryConfig `json:"delivery"`
	Tls      *TlsConfig      `json:"tls"`
	Verbose  bool            `json:"verbose"`
}

Config stores configuration for the application

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig return default configuration

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configuration from file, either in JSON or HJSON

type DeliveryConfig

type DeliveryConfig struct {
	From                  string   `json:"from"`
	CcList                string   `json:"ccList"`
	BccList               string   `json:"bccList"`
	MailFormat            string   `json:"mailFormat"`
	TemplateFiles         []string `json:"templateFiles"`
	TemplateName          string   `json:"templateName"`
	DataFile              string   `json:"dataFile"`
	ToDataField           string   `json:"toDataField"`
	SubjectDataField      string   `json:"subjectDataField"`
	DefaultSubject        string   `json:"defaultSubject"`
	SkipConfirmBeforeSend bool     `json:"skipConfirmBeforeSend"`
	TestAddress           string   `json:"testAddress"`
	SendMode              bool     `json:"sendMode"`
	SentFile              string   `json:"sentFile"`
	SkipIfSent            bool     `json:"skipIfSent"`
	RequiredFields        []string `json:"requiredFields"`
	IntervalBetweenSend   string   `json:"intervalBetweenSend"`
}

DeliveryConfig stores delivery configuration

type Executer

type Executer interface {
	Execute(wr io.Writer, data any) error
}

Executer for different template

func ParseHtmlTemplates

func ParseHtmlTemplates(conf *Config) (Executer, error)

ParseHtmlTemplates parse templates in text format

func ParseTextTemplates

func ParseTextTemplates(conf *Config) (Executer, error)

ParseTextTemplates parse templates in text format

type MailData

type MailData map[string]interface{}

MailData to-be applied to template

func (MailData) HasFields

func (m MailData) HasFields(reqFields []string) bool

func (MailData) StringDefault

func (m MailData) StringDefault(key, def string) string

StringDefault return string value or default

type MailDataCollection

type MailDataCollection struct {
	Data []MailData
}

MailDataCollection stores list of mail data from spreadsheet

func NewMailDataCollection

func NewMailDataCollection(conf *Config) (*MailDataCollection, error)

NewMailDataCollection create mail data collection from files

type Mailer

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

Mailer data structure

func NewMailer

func NewMailer(conf *Config) (*Mailer, error)

func (*Mailer) Send

func (m *Mailer) Send(ctx context.Context) (Stats, error)

type ServerConfig

type ServerConfig struct {
	Authentication string `json:"authentication"`
	Encryption     string `json:"encryption"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	Helo           string `json:"helo"`
	ConnectTimeout string `json:"connectTimeout"`
	SendTimeout    string `json:"sendTimeout"`
	Host           string `json:"host"`
	Port           int    `json:"port"`
	KeepAlive      bool   `json:"keepAlive"`
}

ServerConfig stores connection configuration

func (*ServerConfig) Configure

func (s *ServerConfig) Configure(srv *mail.SMTPServer) error

Configure server

type Stats added in v0.1.1

type Stats struct {
	Total          int
	NumSent        int
	NumAlreadySent int
	NumSkip        int
	NumError       int
}

type TlsConfig

type TlsConfig struct {
	InsecureSkipVerify bool   `json:"insecureSkipVerify"`
	ServerName         string `json:"serverName"`
	CertFile           string `json:"certFile"`
	KeyFile            string `json:"keyFile"`
	ClientAuth         string `json:"clientAuth"`
}

TlsConfig definition

func (*TlsConfig) MakeTlsConfig

func (t *TlsConfig) MakeTlsConfig() (*tls.Config, error)

MakeTlsConfig return tls.Config from given configuration

type Ui

type Ui interface {
	Logf(format string, args ...any) (int, error)
	Confirm(msg string) (int, error)
}

Ui interface

func NewUi

func NewUi(conf *Config) (Ui, error)

NewUi for the console

Directories

Path Synopsis
cmd
sendme command

Jump to

Keyboard shortcuts

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