mail

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Send = func(s SMTPArgs, r Rendered) error {
	d := gomail.NewDialer(s.Host, s.Port, s.Username, s.Password)
	msg := gomail.NewMessage()
	for k, v := range r.Headers {
		msg.SetHeader(k, v...)
	}
	msg.SetBody(r.MimeType, r.Body)
	return d.DialAndSend(msg)
}

Send is an interface for gomail that can be stubbed in testing.

Functions

This section is empty.

Types

type IMailer

type IMailer interface {
	SendVerificationEmail(user user.User) error
}

IMailer is a high-level interface for sending domain mail.

type MailArgs

type MailArgs struct {
	From     string
	To       []string
	Subject  string
	Template string
	Data     any
}

MailArgs is the pre-rendered content of an email using a named template.

type Mailer

type Mailer struct {
	SMTPArgs
	AppDomain string
	Templates templateCache
}

Mailer sends emails using a library of templates.

func New

func New(cfg types.Config) *Mailer

func (*Mailer) Send

func (m *Mailer) Send(args MailArgs) error

Send sends an email with the given content.

func (Mailer) SendVerificationEmail

func (m Mailer) SendVerificationEmail(user user.User) error

type Rendered

type Rendered struct {
	Headers  map[string][]string
	MimeType string
	Body     string
}

Rendered is the rendered headers and body content of an email.

type SMTPArgs

type SMTPArgs struct {
	Host     string
	Port     int
	Username string
	Password string
}

SMTPArgs is the configuration for connecting to an SMTP server.

Jump to

Keyboard shortcuts

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