smtp

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRLF = []byte("\r\n")

CRLF defines the newline

Functions

This section is empty.

Types

type AddressList

type AddressList []*mail.Address

AddressList defines a list of mail.Address

func (AddressList) List

func (list AddressList) List() []string

List returns the list of mail address

func (AddressList) String

func (list AddressList) String() string

type Attachment

type Attachment struct {
	Name        string
	ContentType string
	io.Reader
}

Attachment for mail

type Mail

type Mail struct {
	Subject     string
	PlainText   []byte
	HTML        []byte
	Attachments []*Attachment
}

Mail body for smtp

func (*Mail) AppendAttachment added in v0.4.8

func (mail *Mail) AppendAttachment(attachment *Attachment)

AppendAttachment appends an attachment

func (*Mail) Encode

func (mail *Mail) Encode(from *mail.Address, to AddressList) []byte

Encode encodes mail to mime bytes TODO: add cc and bcc support

type SMTP

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

A SMTP to send mails

func New

func New(host string, port uint16, username string, password string) *SMTP

New returns a smtp client

func (*SMTP) Auth

func (s *SMTP) Auth() (err error)

Auth authorizes the username and password

func (*SMTP) SendMail

func (s *SMTP) SendMail(mail *Mail, from string, to string, oneToOne bool) (err error)

SendMail sends a mail

type SendError

type SendError struct {
	Message string
	From    *mail.Address
	To      AddressList
}

SendError records send a mail error

func (*SendError) Error

func (err *SendError) Error() string

type SendErrors added in v0.4.8

type SendErrors struct {
	Errors []*SendError
}

SendErrors records send mails error

func (*SendErrors) Error added in v0.4.8

func (err *SendErrors) Error() string

Jump to

Keyboard shortcuts

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