mailer

package
v0.0.0-...-3890dee Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginAuth

func LoginAuth(username, password, host string) smtp.Auth

LoginAuth returns an Auth that implements the LOGIN authentication mechanism. The returned Auth uses the given username and password to authenticate to host.

LoginAuth will only send the credentials if the connection is using TLS or is connected to localhost. Otherwise authentication will fail with an error, without sending the credentials.

func ReadFile

func ReadFile[T CSVData](file string) ([]*T, error)

ReadFile reads CSV data and returns the unmarshalled data of type CSVData.

func SendEmailsTLS

func SendEmailsTLS(sender *Sender, emails []*email.Email, host string, auth Auth) (int, error)

SendEmailsTLS sends a list of email messages, defined as instances of github.com/jordan-wright/email.Email, over SMTP.

It returns the slice index of the email message that failed to be sent as well as the reason for the failure.

Arguments:

Types

type Auth

type Auth uint8

Auth is an intermediary representation of a type of supported Auth authentication mechanism

const (
	// Plain represents [Auth] PLAIN authentication
	Plain Auth = iota
	// Login represents [Auth] LOGIN authentication
	Login
	// CRAMMD5 represents [Auth] CRAM-MD5 authentication
	CRAMMD5
)

type CSVData

type CSVData interface{}

CSVData is an empty interface for types which support marshalling to/unmarshalling from raw CSV data.

type List

type List struct {
	// contains filtered or unexported fields
}

List is a convenience type that unmarshals a CSV string and converts it into a of slice of strings, and vice versa.

func (*List) Data

func (l *List) Data() []string

Data is a getter method for the underlying struct data.

func (*List) MarshalCSV

func (l *List) MarshalCSV() (string, error)

MarshalCSV is a helper method which marshals the data from a List struct into a CSV string.

func (*List) UnmarshalCSV

func (l *List) UnmarshalCSV(csv string) error

UnmarshalCSV is a helper method which unmarshals a CSV string into a List struct with []string.

type Receiver

type Receiver struct {
	Email     string     `csv:"email"`
	Cc        *List      `csv:"cc"`
	Bcc       *List      `csv:"bcc"`
	Variables *Variables `csv:"variables"`
}

Receiver represents the recipient of an email message.

type Sender

type Sender struct {
	Email    string `csv:"email"`
	Password string `csv:"password"`
	Name     string `csv:"name"`
}

Sender represents an email sender with the necessary information for authentication.

type Variables

type Variables struct {
	// contains filtered or unexported fields
}

Variables is a convenience type that unmarshals a CSV string with the format "KEY=VALUE" and converts it into a of map of string keys and values, and vice versa.

func (*Variables) Data

func (v *Variables) Data() map[string]string

Data is a getter method for the underlying struct data.

func (*Variables) MarshalCSV

func (v *Variables) MarshalCSV() (string, error)

MarshalCSV is a helper method which marshals the data from a Variables struct into a CSV string.

func (*Variables) UnmarshalCSV

func (v *Variables) UnmarshalCSV(csv string) error

UnmarshalCSV is a helper method which unmarshals a CSV string into a Variables struct with map[string]string data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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