email

package
v0.0.0-...-0d80880 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmailInvalidConfig    = errors.New("invalid SMTP configuration")
	ErrEmailInvalidFrom      = errors.New("invalid 'from' address")
	ErrEmailNoRecipients     = errors.New("failed to provide one recipient")
	ErrEmailInvalidRecipient = errors.New("invalid 'recipient' address")
	ErrEmailSendFailed       = errors.New("failed to send email")
)

Functions

func MockSMTPServerStart

func MockSMTPServerStart(ready chan<- bool, address string)

MockSMTPServerStart starts a mock SMTP server using the provided address. The server will signal on the ready channel when setup is complete.

Types

type RedactedSMTPConfig

type RedactedSMTPConfig SMTPConfig

RedactedSMTPConfig is a copy of SMTPConfig to hide sensitive information.

type SMTPConfig

type SMTPConfig struct {
	Host     string `required:"true"` // Host address.
	Port     string `required:"true"` // Port number.
	Username string `required:"true"` // Username for authentication.
	Password string `required:"true"` // Password for authentication.
}

SMTPConfig holds configuration for an SMTP server for sending emails.

func (SMTPConfig) IsValid

func (s SMTPConfig) IsValid() (bool, error)

IsValid verifies that SMTPConfig has all required fields populated.

func (SMTPConfig) MarshalJSON

func (s SMTPConfig) MarshalJSON() ([]byte, error)

MarshalJSON redacts sensitive information when marshalling to JSON.

func (SMTPConfig) SendMessage

func (s SMTPConfig) SendMessage(from string, recipients []string, subject, body string) error

SendMessage sends an email using the configured SMTP server settings.

func (SMTPConfig) String

func (s SMTPConfig) String() string

String returns a string for SMTPConfig with sensitive data redacted.

Jump to

Keyboard shortcuts

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