mailgo

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 13 Imported by: 1

README

mailgo

SMTP easy to use wrapper library for Go apps.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilMailer = errors.New("no mailer instance")

ErrNilMailer specifies nil mailer instance error

View Source
var ErrNoFrom = errors.New("from option missing")

Functions

func SendMail

func SendMail(recipients []string, subject, plain, html string) []error

SendMail sends mail to given recipients with specified subject and plaintext and HTML message (that's why function requires both). If plaintext of html message is empty, then that format is not used.

func SetupMailer

func SetupMailer(opts ...MailerOption) (err error)

SetupMailer set ups package mailer with specified parameters.

Types

type Mailer

type Mailer struct {
	Host       string
	Port       string
	Name       string
	From       string
	Creds      gosasl.Client
	Localizer  *i18n.Localizer
	ReturnPath string
}

Mailer struct definition.

func NewMailer

func NewMailer(opts ...MailerOption) (*Mailer, error)

NewMailer creates new mailer instance. If we can't create new mailer than error is returned.

func (*Mailer) SendMail

func (m *Mailer) SendMail(recipients []string, subject, plain, html string) (errs []error)

SendMail sends mail to given recipients with specified subject and plaintext and HTML message (that's why function requires both). If plaintext of html message is empty, then that format is not used.

type MailerOption

type MailerOption func(*MailerOptions)

func WithCredentials

func WithCredentials(username, password string) MailerOption

func WithFrom

func WithFrom(from string) MailerOption

func WithHost

func WithHost(host string) MailerOption

func WithName

func WithName(name string) MailerOption

func WithPort

func WithPort(port string) MailerOption

func WithReturnPath added in v1.1.0

func WithReturnPath(returnPath string) MailerOption

type MailerOptions

type MailerOptions struct {
	Host    string
	Port    string
	Name    string
	From    string
	Creds   sasl.Client
	RetPath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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