email

package
v0.0.0-...-1d33cbc Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScheduleSend

func ScheduleSend(ctx context.Context, s *data.Site, m Email) error

ScheduleSend schedules an email to be sent asynchronously by the default task queue. This function uses the default Sender configured for the website.

func ScheduleSendCustom

func ScheduleSendCustom(ctx context.Context, s *data.Site, snd Sender, m Email) error

ScheduleSendCustom schedules an email to be sent asynchronously by the default task queue using the given Sender.

Types

type Attachment

type Attachment struct {
	// Content embeds the attachment data. The value must be base64-encoded.
	Content `json:"content"`

	// Filename is the name of the file to show with the attachment.
	Filename string `json:"filename"`

	// Disposition specifies how the attachment is included in the email.
	// A value may be either "inline" or "attachment"; the default, if this field
	// is left blank, is "attachment".
	Disposition string `json:"disposition"`
}

An Attachment is an email attachment.

type Content

type Content struct {
	// Type is the mime type of the content (for example, "text/plain").
	Type string `json:"type"`

	// Value is the content data.
	Value string `json:"value"`
}

A Content is piece of the content of an email body. Each email must have at least one Content.

func (*Content) MarshalJSON

func (c *Content) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. The error is always nil.

type Copies

type Copies struct {
	CC  []Party `json:"cc"`
	BCC []Party `json:"bcc"`
}

A Copies contains additional recipients to be copied on an email.

func (Copies) MarshalJSON

func (c Copies) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. The error is always nil.

type Email

type Email struct {
	To       Party     `json:"to"`
	From     Party     `json:"from"`
	ReplyTo  Party     `json:"reply_to"`
	Subject  string    `json:"subject"`
	Contents []Content `json:"contents"`
}

An Email represents all the basic settings we use to send emails from the server.

func NewEmail

func NewEmail(toAddress, message string) *Email

NewEmail constructs an Email, setting only the fields that are absolutely required. The mime type of the content is set to text/plain.

func (*Email) MarshalJSON

func (em *Email) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. The error is always nil.

type Party

type Party struct {
	Name    string `json:"name"`
	Address string `json:"address"`
}

A Party is a sender or a receiver of an email.

func (*Party) MarshalJSON

func (p *Party) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. The error is always nil.

type Sender

type Sender interface {
	Send(*Email) error
	SendMulti([]Email) error
}

A Sender is able to send emails. The methods of a Sender do not send emails synchronously: they indicate merely whether an Email is valid and was scheduled to be sent out.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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