mail

package
v0.0.0-...-7b086e4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     int
	Username string
	Password string
	Defaults Defaults
}

Config represents a configuration to connect to an SMTP server

type Defaults

type Defaults struct {
	DefaultTo   string
	DefaultCC   []string
	DefaultBCC  []string
	DefaultFrom string
}

Defaults is the default values for the mailer if none are explicitly mentioned

type Mail

type Mail struct {
	Subject string
	To      string
	Cc      []string
	Bcc     []string
	From    string
	Error   error
	Tpl     *template.Template
	TplData interface{}
}

Mail represents an email to be sent

type Mailer

type Mailer struct {
	*mail.SMTPClient
	Defaults Defaults
}

Mailer is the struct used to send mail, can only be used once connected to mailer

func (*Mailer) CheckSendable

func (m *Mailer) CheckSendable(item Mail) error

CheckSendable verifies that the email can be sent

func (*Mailer) SendMail

func (m *Mailer) SendMail(item Mail) error

SendMail sends a template email

type MailerInit

type MailerInit struct {
	SMTPServer mail.SMTPServer
	Defaults   Defaults
}

MailerInit is the config store for the mailer, can be initialised once then connected multiple times

func NewMailer

func NewMailer(config Config) *MailerInit

NewMailer creates a new SMTP client

func (*MailerInit) ConnectMailer

func (m *MailerInit) ConnectMailer() *Mailer

ConnectMailer connects to the mail server

Jump to

Keyboard shortcuts

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