email

package
v0.0.0-...-4ca8788 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const DEFAULT_FILE_PERM os.FileMode = 0644
View Source
const DEFAULT_FOLDER_PERM os.FileMode = 0777
View Source
const THEME_HTML_FILE = "html.tmpl"
View Source
const THEME_TEXT_FILE = "text.tmpl"
View Source
const TIME_FORMAT = "2006_01_02__15_04_05_000"

Variables

This section is empty.

Functions

func EngineConfigFileYamlLoad

func EngineConfigFileYamlLoad(configFileYaml string, cfg *EngineConfig) (err error)

func LoadSenderConfig

func LoadSenderConfig(configFileYaml string, cfg *Sender) (err error)

Types

type Action

type Action struct {
	Instructions string `yaml:"instructions"`
	Button       Button `yaml:"button"`
	InviteCode   string `yaml:"inviteCode"`
}

Action is anything the user can act on (i.e., click on a button, view an invite code)

func (*Action) ToHermesAction

func (o *Action) ToHermesAction() *hermes.Action

type Body

type Body struct {
	Name       string   `yaml:"name"`       // The name of the contacted person
	Intros     []string `yaml:"intros"`     // Intro sentences, first displayed in the email
	Dictionary []Entry  `yaml:"dictionary"` // A list of key+value (useful for displaying parameters/settings/personal info)
	Table      Table    `yaml:"table"`      // Table is an table where you can put data (pricing grid, a bill, and so on)
	Actions    []Action `yaml:"actions"`    // Actions are a list of actions that the user will be able to execute via a button click
	Outros     []string `yaml:"outros"`     // Outro sentences, last displayed in the email
	Greeting   string   `yaml:"greeting"`   // Greeting for the contacted person (default to 'Hi')
	Signature  string   `yaml:"signature"`  // Signature for the contacted person (default to 'Yours truly')
	Title      string   `yaml:"title"`      // Title replaces the greeting+name when set
}

func (*Body) ToHermesBody

func (o *Body) ToHermesBody() hermes.Body

type Button

type Button struct {
	Color     string `yaml:"color"`
	TextColor string `yaml:"textColor"`
	Text      string `yaml:"text"`
	Link      string `yaml:"link"`
}

Button defines an action to launch

func (*Button) ToHermesButton

func (o *Button) ToHermesButton() hermes.Button

type Columns

type Columns struct {
	CustomWidth     map[string]string
	CustomAlignment map[string]string
}

Columns contains meta-data for the different columns

func (*Columns) ToHermesColumns

func (o *Columns) ToHermesColumns() hermes.Columns

type EmailData

type EmailData struct {
	To       []string
	Name     string
	Subject  string
	Url      string
	Markdown string
	Theme    string
}

func (*EmailData) ToAsString

func (o *EmailData) ToAsString() string

type Engine

type Engine struct {
	hermes.Hermes
	hermes.Body
	Sender
	*encrypt.Encryptor
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(config *EngineConfig) (ret *Engine, err error)

func (*Engine) BuildBody

func (o *Engine) BuildBody(markdown string) (ret hermes.Body)

func (*Engine) BuildEmail

func (o *Engine) BuildEmail(to, subject string, body hermes.Body) (ret *Message, err error)

func (*Engine) Send

func (o *Engine) Send(emailData *EmailData) (err error)

type EngineConfig

type EngineConfig struct {
	EmailsFolder string `yaml:"emailsFolder", envconfig:"PATH_EMAILS"`
	StoreEmails  bool   `yaml:"storeEmails", envconfig:"STORE_EMAILS"`
	Hermes       Hermes `yaml:"hermes"`
	Sender       Sender `yaml:"sender"`
}

func EngineCinfigDefault

func EngineCinfigDefault() (ret *EngineConfig)

func (*EngineConfig) Setup

func (o *EngineConfig) Setup() (err error)

func (*EngineConfig) WriteFileYaml

func (o *EngineConfig) WriteFileYaml(configFileYaml string) (err error)

func (*EngineConfig) WriteSenderConfig

func (o *EngineConfig) WriteSenderConfig(configFileYaml string) (err error)

type Entry

type Entry struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

Entry is a simple entry of a map Allows using a slice of entries instead of a map Because Golang maps are not ordered

func (*Entry) ToHermesEntry

func (o *Entry) ToHermesEntry() hermes.Entry

type Hermes

type Hermes struct {
	ThemesFolder       string `yaml:"themesFolder", envconfig:"PATH_THEMES"`
	Theme              string `yaml:"theme", envconfig:"THEME"`
	TextDirection      string
	Product            Product `yaml:"product"`
	DisableCSSInlining bool    `yaml:"disableCSSInlining"`
	Body               Body    `yaml:"body"`
}

func (*Hermes) ToHermes

func (o *Hermes) ToHermes() hermes.Hermes

type Message

type Message struct {
	To        string
	Subject   string
	HTML      string
	PlainText string
}

type Product

type Product struct {
	Name        string `yaml:"name", envconfig:"PRODUCT_NAME"`
	Link        string `yaml:"link", envconfig:"PRODUCT_LINK"`
	Copyright   string `yaml:"copyright", envconfig:"PRODUCT_COPYRIGHT"`
	TroubleText string `yaml:"troubleText", envconfig:"PRODUCT_TROUBLE_TEXT"`
}

func (*Product) ToHermesProduct

func (o *Product) ToHermesProduct() hermes.Product

type SMTP

type SMTP struct {
	Server   string `yaml:"server", envconfig:"SMTP_SERVER"`
	Port     int    `yaml:"port", envconfig:"SMTP_PORT"`
	User     string `yaml:"user", envconfig:"SMTP_USER"`
	Password string `yaml:"password", envconfig:"SMTP_PASSWORD"`
}

type Sender

type Sender struct {
	Email    string `yaml:"email", envconfig:"SENDER_EMAIL"`
	Identity string `yaml:"identity", envconfig:"SENDER_IDENTITY"`
	SMTP     SMTP   `yaml:"smtp"`
}

func (*Sender) Send

func (o *Sender) Send(message *Message) (err error)

func (*Sender) Setup

func (o *Sender) Setup() (err error)

type Table

type Table struct {
	Data    [][]Entry `yaml:"data"`    // Contains data
	Columns Columns   `yaml:"columns"` // Contains meta-data for display purpose (width, alignement)
}

Table is an table where you can put data (pricing grid, a bill, and so on)

func (*Table) ToHermesTable

func (o *Table) ToHermesTable() *hermes.Table

type Theme

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

func (*Theme) HTMLTemplate

func (o *Theme) HTMLTemplate() string

func (*Theme) Name

func (o *Theme) Name() string

func (*Theme) PlainTextTemplate

func (o *Theme) PlainTextTemplate() string

type Themes

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

func LoadThemes

func LoadThemes(themesFolder string) (ret *Themes)

func (*Themes) LoadTheme

func (o *Themes) LoadTheme(theme string) (ret hermes.Theme)

Jump to

Keyboard shortcuts

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