letter

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A added in v0.15.1

type A struct {
	Filename    string
	Content     []byte
	ContentType string
	Size        int // overrides the actual size if != 0
	Header      textproto.MIMEHeader
}

A contains the fields of Attachment.

type Attachment

type Attachment struct {
	A
}

Attachment is a file attachment.

func NewAttachment added in v0.12.0

func NewAttachment(filename string, content []byte, opts ...AttachmentOption) Attachment

NewAttachment creates an Attachment from the given filename, content and opts.

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 ...mapper.Option) 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 L added in v0.15.0

type L struct {
	Subject     string
	From        mail.Address
	Recipients  []mail.Address
	To          []mail.Address
	CC          []mail.Address
	BCC         []mail.Address
	ReplyTo     []mail.Address
	RFC         string
	Text        string
	HTML        string
	Attachments []Attachment
}

L contains the fields of a Letter.

type Letter

type Letter struct {
	L
	// 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.

If pm implements an RFCConfig() method, it will be used to add an rfc.Config to the Letter.

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 ...mapper.Option) 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) RFCConfig added in v0.12.0

func (l Letter) RFCConfig() rfc.Config

RFCConfig returns the RFC config that is used when calling l.L.RFC().

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.

func (Letter) WithAttachments added in v0.12.0

func (l Letter) WithAttachments(attach ...Attachment) Letter

WithAttachments returns a copy of l with attach as it's attachments.

func (Letter) WithBCC added in v0.12.0

func (l Letter) WithBCC(addrs ...mail.Address) Letter

WithBCC returns a copy of l with addrs as it's `BCC` recipients.

func (Letter) WithCC added in v0.12.0

func (l Letter) WithCC(addrs ...mail.Address) Letter

WithCC returns a copy of l with addrs as it's `CC` recipients.

func (Letter) WithContent added in v0.12.0

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

WithContent returns a copy of l with text as it's text content and html as it's HTML content.

func (Letter) WithFrom added in v0.12.0

func (l Letter) WithFrom(name, addr string) Letter

WithFrom returns a copy of l with an updated `From` field.

func (Letter) WithFromAddress added in v0.12.0

func (l Letter) WithFromAddress(addr mail.Address) Letter

WithFromAddress returns a copy of l with addr as it's `From` field.

func (Letter) WithHTML added in v0.12.0

func (l Letter) WithHTML(h string) Letter

WithHTML returns a copy of h with t as it's HTML content.

func (Letter) WithRFC added in v0.12.5

func (l Letter) WithRFC(rfc string) Letter

WithRFC returns a copy of l with it's rfc body replaced by rfc.

func (Letter) WithRFCConfig added in v0.12.2

func (l Letter) WithRFCConfig(cfg rfc.Config) Letter

WithRFCConfig returns a copy of l with it's rfc configuration replaced by cfg.

func (Letter) WithRFCOptions added in v0.12.0

func (l Letter) WithRFCOptions(opts ...rfc.Option) Letter

WithRFCOptions returns a copy of l with it's rfc configuration replaced.

func (Letter) WithRecipients added in v0.12.0

func (l Letter) WithRecipients(addrs ...mail.Address) Letter

WithRecipients returns a copy of l with addrs as it's recipients.

func (Letter) WithReplyTo added in v0.12.0

func (l Letter) WithReplyTo(addrs ...mail.Address) Letter

WithReplyTo returns a copy of l with addrs as it's `ReplyTo` field.

func (Letter) WithSubject added in v0.12.0

func (l Letter) WithSubject(s string) Letter

WithSubject returns a copy of l withs it's subject set to s.

func (Letter) WithText added in v0.12.0

func (l Letter) WithText(t string) Letter

WithText returns a copy of l with t as it's text content.

func (Letter) WithTo added in v0.12.0

func (l Letter) WithTo(addrs ...mail.Address) Letter

WithTo returns a copy of l with addrs as it's `To` recipients.

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
rfc
mocks
Package mock_rfc is a generated GoMock package.
Package mock_rfc is a generated GoMock package.

Jump to

Keyboard shortcuts

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