message

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(addr string, auth smtp.Auth, ed *EmailData) error

Send sends the message.

Types

type Email

type Email struct {
	core.QueueItem
	Credentials *EmailCredentials
	Data        *EmailData
}

func (*Email) MarshalBinary

func (e *Email) MarshalBinary() ([]byte, error)

func (*Email) UnmarshalBinary

func (e *Email) UnmarshalBinary(data []byte) error

type EmailAttachment

type EmailAttachment struct {
	Filename string `json:"filename"`
	Data     []byte `json:"data"`
	Inline   bool   `json:"inline"`
}

EmailAttachment represents an email attachment.

type EmailCredentials

type EmailCredentials struct {
	Address  string `json:"address"`
	Hostname string `json:"hostname"`
	Name     string `json:"name"`
	Port     string `json:"port"`
	Password string `json:"password"`
}

EmailCredentials stores the relevant credenial data to send emails.

func (*EmailCredentials) LoadFromConfig

func (ec *EmailCredentials) LoadFromConfig(dir string) error

LoadFromConfig loads the email credentials from a JSON config file.

type EmailData

type EmailData struct {
	From            mail.Address                `json:"from"`
	To              []string                    `json:"to"`
	Cc              []string                    `json:"cc"`
	Bcc             []string                    `json:"bcc"`
	ReplyTo         string                      `json:"replyto"`
	Subject         string                      `json:"subject"`
	Body            string                      `json:"body"`
	BodyContentType string                      `json:"bodycontenttype"`
	Headers         []Header                    `json:"headers"`
	Attachments     map[string]*EmailAttachment `json:"attachments"`
}

EmailData represents a smtp message.

func NewHTMLMessage

func NewHTMLMessage(subject string, body string) *EmailData

NewHTMLMessage returns a new EmailData that can compose an HTML email with attachments

func NewPlainTextMessage

func NewPlainTextMessage(subject string, body string) *EmailData

NewPlainTextMessage returns a new EmailData that can compose an email with attachments

func (*EmailData) AddAttachment

func (ed *EmailData) AddAttachment(file string, inline bool) error

AddAttachment adds a new attachment to the message.

func (*EmailData) AddHeader

func (ed *EmailData) AddHeader(key string, value string) Header

AddHeader ads a Header to message

func (*EmailData) AttachBuffer

func (ed *EmailData) AttachBuffer(filename string, buf []byte, inline bool) error

AttachBuffer attaches a binary attachment.

func (*EmailData) Data

func (ed *EmailData) Data() []byte

Data returns all the message data as a byte array.

func (*EmailData) GetRecipients

func (ed *EmailData) GetRecipients() []string

GetRecipients returns all the recipients of the message.

type Header struct {
	Key   string
	Value string
}

Header represents an additional email header.

type Service

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

Service handles emails and other simlar functionality within the package.

func (*Service) Check

func (s *Service) Check()

func (*Service) DequeueEmail

func (s *Service) DequeueEmail() error

func (*Service) EnqueueEmail

func (s *Service) EnqueueEmail(e *Email) error

func (*Service) Listen

func (s *Service) Listen(w http.ResponseWriter, r *http.Request)

func (*Service) Startup

func (s *Service) Startup() error

Jump to

Keyboard shortcuts

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