mail

package module
v0.0.0-...-7a4ae82 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 8 Imported by: 0

README

mailer

unit file format for configuration and mail setup

/etc/example.mail

user=example@gmail.com
pass=
smtp=smtp.gmail.com

[admin]
mail=admin@gmail.com

Simple use case


	environ := env.NewEnv()

	// configure mail and store unit file path for later reference
	mailer := mail.NewMail( 
		env.Dir(environ.Etc, "example.mail"),
		"gmail",
	)

// send an admin alert using the stored unit file
	mailer.Alert().Send( // send an admin alert
		"admin",              // to; process [section] from the saved unit file
		nil,                  // subject
		"something happened", // message
	)



Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mail

type Mail struct {
	To      []string
	Subject string
	Message string
	// contains filtered or unexported fields
}

Mail mailer struct

func NewMail

func NewMail(path string, a ...string) *Mail

NewMail *Mail unit based configurator and stores the unit file for futrue use; requires path,section ordering

func NewMailer

func NewMailer(user, pass, smtp string) *Mail

NewMailer *Mail configurator

func (*Mail) Alert

func (mail *Mail) Alert() *Mail

Alert sets the alert boolean flag

func (*Mail) FromFile

func (mail *Mail) FromFile(path string) *Mail

FromFile populates mail.To from \n delimited file

func (*Mail) FromUnit

func (mail *Mail) FromUnit(path *string, a ...string) *Mail

FromUnit populates mail.To from a unit file

[section]

mail=address,address

func (*Mail) NewLine

func (mail *Mail) NewLine() string

NewLine character

func (*Mail) Send

func (mail *Mail) Send(to, subject, message interface{}) bool

Send with auto reset

To: @email, FromFile, unit [section]

Subject: nil, string and/or use .Alert()

Message: string or []string for multiple lines

Jump to

Keyboard shortcuts

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