Documentation
¶
Index ¶
- Variables
- type FromAddressFunc
- type InlineAttachment
- type InlineAttachmentAdder
- type Mail
- type MailInstance
- type MailOpt
- func Bcc(to ...string) MailOpt
- func From(from mail.Address) MailOpt
- func HtmlBody(body string) MailOpt
- func HtmlBodyTemplate(tmpl *template.Template, data any) MailOpt
- func Inline(contentID, contentType string, data []byte) MailOpt
- func ReplyTo(to string) MailOpt
- func Subject(subject string) MailOpt
- func TextBody(body string) MailOpt
- func To(to ...string) MailOpt
- type Mailer
- type MailerAdapter
- type MailerConfig
- type Noop
- func (n *Noop) AddInlineAttachment(InlineAttachment) error
- func (n *Noop) Bcc([]string) error
- func (n *Noop) From(string) error
- func (n *Noop) HtmlBody(string) error
- func (n *Noop) NewMail(context.Context) (MailInstance, error)
- func (n *Noop) ReplyTo(string) error
- func (n *Noop) Send(context.Context) error
- func (n *Noop) Subject(string) error
- func (n *Noop) TextBody(string) error
- func (n *Noop) To([]string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInlineAttachmentsNotSupported is returned by Mailer.Send for a mail with // inline attachments if the adapter's MailInstance does not implement // InlineAttachmentAdder. ErrInlineAttachmentsNotSupported = errors.New("mailx: adapter does not support inline attachments") // ErrInvalidInlineAttachment is wrapped by the errors Mailer.Send returns for // an invalid inline attachment. ErrInvalidInlineAttachment = errors.New("mailx: invalid inline attachment") )
Functions ¶
This section is empty.
Types ¶
type FromAddressFunc ¶
func MailOverrideFromAddress ¶
func MailOverrideFromAddress() FromAddressFunc
func StaticFromAddress ¶
func StaticFromAddress(address string) FromAddressFunc
type InlineAttachment ¶ added in v1.1.0
type InlineAttachment struct {
ContentID string // referenced from HTML as "cid:<ContentID>", without angle brackets
ContentType string // e.g. "image/png"
Data []byte
}
InlineAttachment is a file embedded in the mail, typically an image that the HTML body references by its Content-ID, e.g. <img src="cid:logo">.
type InlineAttachmentAdder ¶ added in v1.1.0
type InlineAttachmentAdder interface {
AddInlineAttachment(InlineAttachment) error
}
InlineAttachmentAdder may be implemented by a MailInstance that supports inline attachments. Mailer.Send returns ErrInlineAttachmentsNotSupported for a mail with inline attachments if the instance does not implement it.
type Mail ¶
type MailInstance ¶
type MailOpt ¶
type MailOpt func(mail *Mail)
func Inline ¶ added in v1.1.0
Inline embeds data in the mail so that the HTML body can reference it as "cid:<contentID>". The adapter must implement InlineAttachmentAdder.
type Mailer ¶
type Mailer struct {
MailerAdapter
Config *MailerConfig
}
type MailerAdapter ¶
type MailerAdapter interface {
NewMail(context.Context) (MailInstance, error)
}
type MailerConfig ¶
type MailerConfig struct {
FromAddressSrc []FromAddressFunc
}
func (*MailerConfig) GetActualFromAddress ¶
func (mc *MailerConfig) GetActualFromAddress(ctx context.Context, mail Mail) string
type Noop ¶
type Noop struct{}
func (*Noop) AddInlineAttachment ¶ added in v1.1.0
func (n *Noop) AddInlineAttachment(InlineAttachment) error