mail

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsParagraph added in v0.5.4

func AsParagraph(text string, style string) string

AsParagraph escapes `text` and wraps it into <p> and </p>

func DialServer

func DialServer(server, username, password string) (*smtp.Client, error)

DialServer dials a SMTP server using provided arguments. The 'server' argument should also contain a port number (e.g. 'localhost:25'). Anything other than port 25 is considered to be a connection with authentication over TLS.

func SendNotification

func SendNotification[T EmailNotificationMessage](conf *NotificationConf, location *time.Location, msg T) error

SendNotification sends a general e-mail notification. Based on configuration, it is able to use SMTP servers requiring TLS and authentication (see Dial()).

Types

type EmailNotificationMessage added in v0.5.4

type EmailNotificationMessage interface {
	Notification | FormattedNotification
}

type FormattedNotification added in v0.5.4

type FormattedNotification struct {
	Subject string
	Divs    []string
}

FormattedNotification allows sending raw html message (i.e. nothing is HTMP escaped)

type Notification added in v0.0.5

type Notification struct {
	Subject    string
	Paragraphs []string
}

Notification represents a general notification e-mail subject and body. The contents of `Paragraphs` is always escaped by the notification function. (for raw HTML formatted notifications, use `FormattedNotification`)

type NotificationConf

type NotificationConf struct {
	Sender       string   `json:"sender"`
	Recipients   []string `json:"recipients"`
	SMTPServer   string   `json:"smtpServer"`
	SMTPUsername string   `json:"smtpUsername"`
	SMTPPassword string   `json:"smtpPassword"`
	// Signature defines multi-language signature for notification e-mails
	Signature map[string]string `json:"signature"`
}

NotificationConf configures e-mail-based notification

func (NotificationConf) WithRecipients added in v0.0.6

func (nc NotificationConf) WithRecipients(r ...string) NotificationConf

WithRecipients creates a new NotificationConf instance with recipients overwritten by the provided ones

Jump to

Keyboard shortcuts

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