mail

package
v1.2.147 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMailClient

type IMailClient interface {
	MailUsr() string
	CreateTextMessage() IMailMessage
	CreateHtmlMessage() IMailMessage
	CreateJsonMessage() IMailMessage
	CreateTemplateMessage(template TemplateName, variables map[string]string) IMailMessage
}

IMailClient Mail client interface

func NewMailClient

func NewMailClient(config MailConfig) (IMailClient, error)

NewMailClient is a Mail client factory method

type IMailMessage

type IMailMessage interface {
	From(from string) IMailMessage
	To(to []string) IMailMessage
	Cc(cc []string) IMailMessage
	Bcc(bcc []string) IMailMessage
	Subject(subject string) IMailMessage
	Body(body string) IMailMessage
	HtmlBody(html string) IMailMessage
	Attachments(attachments []MailMessageAttachment) IMailMessage

	AddTo(to ...string) IMailMessage
	AddCc(cc ...string) IMailMessage
	AddBcc(bcc ...string) IMailMessage
	AddAttachments(attachments ...MailMessageAttachment) IMailMessage
	Attach(paths ...string) IMailMessage

	Send() error
}

IMailMessage Mail message interface

type MailConfig

type MailConfig struct {

	// Mail relay URI (type://host:port)
	MailRelayUri string

	// Mail Relay User
	MailRelayUser string

	// Mail Relay Password
	MailRelayPassword string

	// Flag to use TLS encrypted connection (applicable for SMTP mail only)
	UseTLS bool

	// List of HTTP headers (applicable for HTTP mail only)
	Headers map[string]string
}

MailConfig Configure mail client parameters

func NewMailConfig added in v1.2.146

func NewMailConfig(uri string) *MailConfig

NewMailConfig factory method

func (*MailConfig) CreateClient added in v1.2.146

func (mc *MailConfig) CreateClient() (IMailClient, error)

CreateClient create concrete implementation of mail client

func (*MailConfig) SetHeader added in v1.2.146

func (mc *MailConfig) SetHeader(header, value string) *MailConfig

SetHeader set HTTP header

func (*MailConfig) WithPassword added in v1.2.146

func (mc *MailConfig) WithPassword(value string) *MailConfig

WithPassword set mail relay password

func (*MailConfig) WithTLS added in v1.2.146

func (mc *MailConfig) WithTLS(value bool) *MailConfig

WithTLS set TLS flag

func (*MailConfig) WithUser added in v1.2.146

func (mc *MailConfig) WithUser(value string) *MailConfig

WithUser set mail relay user

type MailMessageAttachment

type MailMessageAttachment struct {
	// File name or the full file path (in case the file content is not provided) to attach
	FileName string `json:"fileName"`

	// Base64 content of the file
	Content string `json:"content"`

	// MIME type, if the content is provided as base64 in the Content field, it should include the suffix: ;base64
	ContentType string `json:"contentType"`
}

MailMessageAttachment represents message attachment

type TemplateName

type TemplateName string

Jump to

Keyboard shortcuts

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