mail

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an email client that can send emails using the specified configuration.

func New

func New(cfg *Config) *Client

New creates a new Client instance using the provided configuration. It initializes the Client with the host, port, username, password, and identity.

func (*Client) Mailing added in v1.0.8

func (c *Client) Mailing(emails []string, message string, subject string, contentType string) error

Mailing sends a message to a list of recipients with the given message, subject, and content type.

func (*Client) PersonalMailing added in v1.0.8

func (c *Client) PersonalMailing(values map[string][]interface{}, template string, subject string, contentType string) error

PersonalMailing sends a message to a list of recipients substituting values into given template. The template format should be the same as for fmt`s functions. The values are taken from a multiple, where the key is the recipient's mail, and the value is an array of values that will be substituted into the template. Be careful with the order of values in the template and the array of values.

func (*Client) Send

func (c *Client) Send(to string, message string, subject string, contentType string) error

Send sends an email to the specified recipient with the given message, subject, and content type. It uses SMTP authentication and constructs the email message in the required format.

type Config

type Config struct {
	Host     string `yaml:"host"     env:"MAIL_HOST"`     // The SMTP server hostname
	Port     int    `yaml:"port"     env:"MAIL_PORT"`     // The SMTP server port
	Username string `yaml:"username" env:"MAIL_USERNAME"` // The username for authentication
	Password string `env:"MAIL_PASSWORD" `                // The password for authentication
	Identity string `yaml:"identity" env:"MAIL_IDENTITY"` // The identity of the sender
}

Config holds the configuration for the email client. It includes fields for the mail server host, port, username, password, and identity.

Jump to

Keyboard shortcuts

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