email

package
v0.0.0-...-c6dbdfa Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfirmEmailTemplateEN *template.Template = template.Must(template.New("confirmEmailTemplateSrcEN").Parse(confirmEmailTemplateSrcEN))
View Source
var OutgoingEmailsChannel chan *Email

OutgoingEmailsChannel is a light-weight go-routine to send emails

View Source
var RequestPasswordTokenTemailTemplateEN *template.Template = template.Must(template.New("requestPasswordTokenTemailTemplateSrcEN").Parse(requestPasswordTokenTemailTemplateSrcEN))
View Source
var TerminalMail = NewTerminalMailer()

TerminalMail is ready-to-use instance for displaying emails in the terminal

View Source
var VoidMail = NewVoidMailer()

VoidMail is ready-to-use instance for dropping outgoing emails

Functions

func BackgroundSend

func BackgroundSend(emails <-chan *Email)

BackgroundSend will send emails enqueued in a channel

func FillTemplate

func FillTemplate(t *template.Template, data map[string]string) (string, error)

FillTemplate loads a template and fills out the placeholders.

Types

type Email

type Email struct {
	From    string
	ReplyTo string
	To      string
	Subject string
	Body    string
}

Email contains all information to use sendmail

func NewEmail

func NewEmail(from string, toEmail string, subject string, body string) *Email

NewEmail creates a new email structure

func NewEmailFromTemplate

func NewEmailFromTemplate(from string, toEmail string, subject string, tpl *template.Template, data map[string]string) (*Email, error)

NewEmailFromTemplate creates a new email structure filling a template file

func NewEmailFromUser

func NewEmailFromUser(from string, toEmail string, subject string, body string, user *model.User) *Email

NewEmailFromUser creates a new email structure and appends the sender information

type Emailer

type Emailer interface {
	Send(e *Email) error
}

Emailer any object that can send

var DefaultMail Emailer

DefaultMail is the default instance used by infomark

type SendMailer

type SendMailer struct {
	Binary string
}

SendMailer uses the sendmail binary to send emails.

var SendMail *SendMailer

SendMail is ready-to-use instance for sendmail

func NewSendMailer

func NewSendMailer(sendmailBinary string) *SendMailer

NewSendMailer creates an object that will send emails over sendmail

func (*SendMailer) Send

func (sm *SendMailer) Send(e *Email) error

Send uses `sendmail` to deliver emails.

type TerminalMailer

type TerminalMailer struct{}

TerminalMailer prints the email to the terminal.

func NewTerminalMailer

func NewTerminalMailer() *TerminalMailer

NewTerminalMailer creates an object that printout the email in the terminal

func (*TerminalMailer) Send

func (sm *TerminalMailer) Send(e *Email) error

Send prints everything to stdout.

type VoidMailer

type VoidMailer struct{}

VoidMailer does nothing (to keep the unit test outputs clean)

func NewVoidMailer

func NewVoidMailer() *VoidMailer

NewVoidMailer creates an object that drops any email

func (*VoidMailer) Send

func (sm *VoidMailer) Send(e *Email) error

Send will drop any outgoing email

Jump to

Keyboard shortcuts

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