mail

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorParamsEmpty errors.CodeError = iota + errors.MinPkgMail
	ErrorIORead
	ErrorIOWrite
	ErrorDateParsing
	ErrorSmtpClient
	ErrorSenderInit
)
View Source
const (
	RecipientTo recipientType = iota
	RecipientCC
	RecipientBCC
)
View Source
const (
	DateTimeLayout = time.RFC1123Z
)

Variables

This section is empty.

Functions

func IsCodeError

func IsCodeError() bool

Types

type Body

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

contents represents the different content parts of an email body.

func NewBody

func NewBody(ct ContentType, body io.Reader) Body

type ContentType

type ContentType uint8
const (
	// ContentPlainText sets body type to text/plain in message body.
	ContentPlainText ContentType = iota
	// ContentHTML sets body type to text/html in message body.
	ContentHTML
)

func (ContentType) String

func (c ContentType) String() string

type Email

type Email interface {
	SetFrom(mail string)
	GetFrom() string

	SetSender(mail string)
	GetSender() string

	SetReplyTo(mail string)
	GetReplyTo() string

	SetReturnPath(mail string)
	GetReturnPath() string

	SetRecipients(rt recipientType, rcpt ...string)
	AddRecipients(rt recipientType, rcpt ...string)
	GetRecipients(rt recipientType) []string
}

type Encoding

type Encoding uint8
const (
	// EncodingNone turns off encoding on the message body.
	EncodingNone Encoding = iota

	// EncodingBinary is equal to EncodingNone, but string is set to binary instead of none.
	EncodingBinary

	// EncodingBase64 sets the message body encoding to base64.
	EncodingBase64

	// EncodingQuotedPrintable sets the message body encoding to quoted-printable.
	EncodingQuotedPrintable
)

func (Encoding) String

func (e Encoding) String() string

type File

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

file represents the files that can be added to the email message.

func NewFile

func NewFile(name string, mime string, data io.ReadCloser) File

type Mail

type Mail interface {
	SetCharset(charset string)
	GetCharset() string

	SetPriority(p Priority)
	GetPriority() Priority

	SetSubject(subject string)
	GetSubject() string

	SetEncoding(enc Encoding)
	GetEncoding() Encoding

	SetDateTime(datetime time.Time)
	GetDateTime() time.Time
	SetDateString(layout, datetime string) liberr.Error
	GetDateString() string

	AddHeader(key string, values ...string)
	GetHeader(key string) []string
	GetHeaders() textproto.MIMEHeader

	SetBody(ct ContentType, body io.ReadCloser)
	AddBody(ct ContentType, body io.ReadCloser)
	GetBody() []Body

	SetAttachment(name string, mime string, data io.ReadCloser, inline bool)
	AddAttachment(name string, mime string, data io.ReadCloser, inline bool)
	AttachFile(filepath string, data io.ReadCloser, inline bool)
	GetAttachment(inline bool) []File

	Email() Email

	Sender() (Sender, liberr.Error)
}

func New

func New() Mail

type Priority

type Priority uint8
const (
	// PriorityNormal sets the email priority to normal.
	PriorityNormal Priority = iota
	// PriorityLow sets the email priority to Low.
	PriorityLow
	// PriorityHigh sets the email priority to High.
	PriorityHigh
)

func (Priority) String

func (p Priority) String() string

type Sender

type Sender interface {
	Close() error
	Send(ctx context.Context, cli libsmtp.SMTP) liberr.Error
	SendClose(ctx context.Context, cli libsmtp.SMTP) liberr.Error
}

Jump to

Keyboard shortcuts

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