letter

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

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

Attachment is a file attachment.

func (Attachment) Content

func (at Attachment) Content() []byte

Content returns the file contents of the Attachment.

func (Attachment) ContentType

func (at Attachment) ContentType() string

ContentType returns the `Content-Type` of the Attachment.

func (Attachment) Filename

func (at Attachment) Filename() string

Filename returns the filename of the Attachment.

func (Attachment) Header

func (at Attachment) Header() textproto.MIMEHeader

Header returns the MIME headers of the Attachment.

func (Attachment) Map added in v0.8.0

func (at Attachment) Map(opts ...MapOption) map[string]interface{}

Map maps at to a map[string]interface{}. Use WithoutContent() option to clear the attachment content in the map.

func (*Attachment) Parse added in v0.8.0

func (at *Attachment) Parse(m map[string]interface{})

Parse parses the map m and applies the values to at.

func (Attachment) Size added in v0.8.0

func (at Attachment) Size() int

Size returns the filesize of the Attachment.

type AttachmentOption added in v0.8.0

type AttachmentOption func(*Attachment)

AttachmentOption configures an attachment.

func AttachmentSize added in v0.8.0

func AttachmentSize(s int) AttachmentOption

AttachmentSize returns an AttachmentOption that explicitly sets / overrides it's size.

func AttachmentType added in v0.8.0

func AttachmentType(ct string) AttachmentOption

AttachmentType sets the `Content-Type` of the attachment.

type Letter

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

Letter represents a mail.

func Expand added in v0.8.0

func Expand(pm postdog.Mail) Letter

Expand converts the postdog.Mail pm to a Letter.

Add additional information

If pm implements any of the optional methods To(), CC(), BCC(), ReplyTo(), Subject(), Text(), HTML() or Attachments(), those methods will be called to retrieve the information which will be added to the returned Letter.

If pm has an Attachments() method, the return type of that method must be a slice of a type that implements the following methods: Filename() string, Content() []byte, ContentType() string, Header() textproto.MIMEHeader.

func Must

func Must(let Letter, err error) Letter

Must panics if err is not nil and otherwise returns let.

func New

func New(opts ...Option) (Letter, error)

New is an alias for TryWrite().

func TryWrite added in v0.8.0

func TryWrite(opts ...Option) (Letter, error)

TryWrite a letter with the given opts.

func Write

func Write(opts ...Option) Letter

Write a letter with the given opts. Panics if TryWrite() returns an error.

func (Letter) Attachments

func (l Letter) Attachments() []Attachment

Attachments returns the attachments of the letter.

func (Letter) BCC

func (l Letter) BCC() []mail.Address

BCC returns the `Bcc` recipients of the letter.

func (Letter) CC

func (l Letter) CC() []mail.Address

CC returns the `Cc` recipients of the letter.

func (Letter) Content added in v0.8.0

func (l Letter) Content() (text string, html string)

Content returns both the text and HTML content of the letter.

func (Letter) From

func (l Letter) From() mail.Address

From returns the sender of the letter.

func (Letter) HTML

func (l Letter) HTML() string

HTML returns the HTML content of the letter.

func (Letter) Map added in v0.8.0

func (l Letter) Map(opts ...MapOption) map[string]interface{}

Map maps l to a map[string]interface{}. Use WithoutContent() option to clear the attachment contents in the map.

func (*Letter) Parse added in v0.8.0

func (l *Letter) Parse(m map[string]interface{})

Parse parses m into l.

func (Letter) RFC

func (l Letter) RFC() string

RFC returns the letter as a RFC 5322 string.

func (Letter) Recipients added in v0.8.0

func (l Letter) Recipients() []mail.Address

Recipients returns all recipients of the letter.

func (Letter) ReplyTo added in v0.7.0

func (l Letter) ReplyTo() []mail.Address

ReplyTo returns the `Reply-To` recipients of the letter.

func (Letter) String

func (l Letter) String() string

func (Letter) Subject

func (l Letter) Subject() string

Subject returns the subject of the letter.

func (Letter) Text

func (l Letter) Text() string

Text returns the text content of the letter.

func (Letter) To

func (l Letter) To() []mail.Address

To returns the `To` recipients of the letter.

type MapOption added in v0.8.0

type MapOption func(*mapConfig)

MapOption configures a Map() call.

func WithoutAttachmentContent added in v0.8.0

func WithoutAttachmentContent() MapOption

WithoutAttachmentContent returns a MapOption that clears the content of one or multiple Attachments.

type Option added in v0.8.0

type Option func(*Letter) error

Option modifies a letter.

func Attach

func Attach(filename string, content []byte, opts ...AttachmentOption) Option

Attach adds a file attachment to the letter.

func AttachFile

func AttachFile(filename, path string, opts ...AttachmentOption) Option

AttachFile adds the file in path as an attachment to the letter.

func AttachReader added in v0.8.0

func AttachReader(filename string, r io.Reader, opts ...AttachmentOption) Option

AttachReader adds a file attachment to the letter.

func BCC

func BCC(name, addr string) Option

BCC adds a `Bcc` recipient to the letter.

func BCCAddress

func BCCAddress(addrs ...mail.Address) Option

BCCAddress adds a `Bcc` recipient to the letter.

func CC

func CC(name, addr string) Option

CC adds a `Cc` recipient to the letter.

func CCAddress

func CCAddress(addrs ...mail.Address) Option

CCAddress adds a `Cc` recipient to the letter.

func Content

func Content(text, html string) Option

Content sets both the text and HTML content of the letter.

func From

func From(name, addr string) Option

From sets the sender of the letter.

func FromAddress

func FromAddress(addr mail.Address) Option

FromAddress sets sender of the letter.

func HTML

func HTML(s string) Option

HTML sets the HTML content of the letter.

func RFC added in v0.8.0

func RFC(body string) Option

RFC returns an Option that

func Recipient added in v0.8.0

func Recipient(name, addr string) Option

Recipient returns an Option that adds a recipient to a mail. It does NOT add the recipient as to the `To` header of a mail.

func RecipientAddress added in v0.8.0

func RecipientAddress(addrs ...mail.Address) Option

RecipientAddress returns an Option that adds a recipient to a mail. It does NOT add the recipient as to the `To` header of a mail.

func ReplyTo added in v0.7.0

func ReplyTo(name, addr string) Option

ReplyTo adds a `Reply-To` recipient to the letter.

func ReplyToAddress added in v0.7.0

func ReplyToAddress(addrs ...mail.Address) Option

ReplyToAddress adds a `Reply-To` recipient to the letter.

func Subject

func Subject(s string) Option

Subject sets the `Subject` header.

func Text

func Text(s string) Option

Text sets the text content of the letter.

func To

func To(name, addr string) Option

To adds a `To` recipient to the letter.

func ToAddress

func ToAddress(addrs ...mail.Address) Option

ToAddress adds a `To` recipient to the letter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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