email

package
v0.0.0-...-65546df Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TemplateCaptcha = "captcha.tmpl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	ContentType mail.ContentType `mapstructure:"contentType"`
	From        string           `mapstructure:"from"`
	To          []string         `mapstructure:"to"`
	CC          []string         `mapstructure:"cc"`
	Bcc         []string         `mapstructure:"bcc"`
	Subject     string           `mapstructure:"subject"`
	Message     any              `mapstructure:"message"`
	Template    string           `mapstructure:"template"`
}

Message represents an email message

type Options

type Options struct {
	// smtp server host
	Host    string
	SSLPort bool
	// smtp server port
	Port     int
	Username string
	Password string
	// email template resolve dir
	TemplateDir string
}

type Sender

type Sender struct {
	Options Options
	// contains filtered or unexported fields
}

Sender is responsible for sending email

func NewSender

func NewSender(options Options) (*Sender, error)

NewSender initialize email sender

func (*Sender) BuildEmail

func (s *Sender) BuildEmail(msg Message) (*mail.Msg, error)

BuildEmail builds *mail.Msg from Message

func (*Sender) ParseTemplate

func (s *Sender) ParseTemplate(name string, data any) ([]byte, error)

ParseTemplate parse specified named template with given data

func (*Sender) SendEmail

func (s *Sender) SendEmail(ctx context.Context, message Message) error

SendEmail sends an email with given message

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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