mailer

package
v1.0.0-rc Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mail

type Mail struct {
	Domain      string
	Templates   string
	Host        string
	Port        int
	Username    string
	Password    string
	Encryption  string
	FromAddress string
	FromName    string
	Jobs        chan Message
	Results     chan Result
	API         string
	APIKey      string
	APIUrl      string
}

func (*Mail) ListenForMail

func (m *Mail) ListenForMail()

Listen on the mail channel and send when a payload is received. The method will run continually in the background and send error or success messages on the results channel.

func (*Mail) Send

func (m *Mail) Send(msg Message) error

Determines the appropriate method for sending an email message. If a third-party API is configured (API name is set and not "smtp", and both APIKey and APIUrl are provided), it delegates the sending to chooseAPI. Otherwise, it defaults to sending the message via SMTP.

func (*Mail) SendSMTPMessage

func (m *Mail) SendSMTPMessage(msg Message) error

Sends an email using SMTP with HTML and plain text bodies. It sets default sender values, configures the SMTP client, attaches any files, and sends the message using the SMTP protocol.

func (*Mail) SendUsingAPI

func (m *Mail) SendUsingAPI(msg Message, transport string) error

Sends an email using a specified API transport. It builds the email message, sets default sender values if missing, attaches files, and uses the configured API client to transmit the message.

type Message

type Message struct {
	From        string
	FromName    string
	To          string
	Subject     string
	Template    string
	Attachments []string
	Data        interface{}
}

Message is the type for an email message

type Result

type Result struct {
	Success bool
	Error   error
}

Result contains information regarding the status of the sent email message

Jump to

Keyboard shortcuts

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