goemail

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: ISC Imports: 13 Imported by: 8

README

goemail

GoDoc

License

goemail is licensed under the copyfree ISC License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidScheme = errors.New("invalid scheme")
	ErrNoRecipients  = errors.New("no recipients specified")
)

Define errors

Functions

func IsValidAddress

func IsValidAddress(addr string) bool

IsValidAddress validates the input email address, returning false if the address cannot be parsed by mail.ParseAddress.

Types

type Message

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

Message defines an email message, headers, and attachments.

func NewHTMLMessage

func NewHTMLMessage(from, subject, body string) *Message

NewHTMLMessage creates a new text/html email.

func NewMessage

func NewMessage(from, subject, body string) *Message

NewMessage creates a new text/plain email.

func NewMessageType

func NewMessageType(from, subject, body, contentType string) *Message

NewMessageType creates a new email with the specified content-type.

func (*Message) AddAttachment

func (m *Message) AddAttachment(filename string, attachment []byte)

AddAttachment adds the provided attachment to the message.

func (*Message) AddAttachmentFromFile

func (m *Message) AddAttachmentFromFile(filename string) error

AddAttachmentFromFile adds an attachment specified by filename to the message.

func (*Message) AddBCC

func (m *Message) AddBCC(emailAddr string)

AddBCC adds a single email address to the BCC list.

func (*Message) AddCC

func (m *Message) AddCC(emailAddr string)

AddCC adds a single email address to the CC list.

func (*Message) AddTo

func (m *Message) AddTo(emailAddr string)

AddTo adds an email address to the To recipients.

func (*Message) Body

func (m *Message) Body() []byte

Body returns the formatted message body.

func (*Message) From

func (m *Message) From() string

From returns the sender's email address

func (*Message) Name

func (m *Message) Name() string

Name returns the sender's display name.

func (*Message) Recipients

func (m *Message) Recipients() []string

Recipients returns an array of all the recipients, which includes To, CC, and BCC

func (*Message) SetName

func (m *Message) SetName(name string)

SetName sets the sender's display name.

type SMTP

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

SMTP defines and smtp server along with the auth info.

func NewSMTP

func NewSMTP(rawURL string, tlsConfig *tls.Config) (*SMTP, error)

NewSMTP is called with smtp[s]://[username:[password]]@server:[port]

func (*SMTP) Send

func (s *SMTP) Send(msg *Message) error

Send connects to the server and sends the email message.

Jump to

Keyboard shortcuts

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