email

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Magistrala Email Agent

Magistrala Email Agent is used for sending emails. It wraps basic SMTP features and provides a simple API that Magistrala services can use to send email notifications.

Configuration

Magistrala Email Agent is configured using the following configuration parameters:

Parameter Description
MG_EMAIL_HOST Mail server host
MG_EMAIL_PORT Mail server port
MG_EMAIL_USERNAME Mail server username
MG_EMAIL_PASSWORD Mail server password
MG_EMAIL_FROM_ADDRESS Email "from" address
MG_EMAIL_FROM_NAME Email "from" name
MG_EMAIL_TEMPLATE Email template for sending notification emails

There are two authentication methods supported: Basic Auth and CRAM-MD5. If MG_EMAIL_USERNAME is empty, no authentication will be used.

Documentation

Overview

Package email contains the domain concept definitions needed to support Magistrala email functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent for mailing.

func New

func New(c *Config) (*Agent, error)

New creates new email agent.

func (*Agent) Send

func (a *Agent) Send(to []string, from, subject, header, user, content, footer string) error

Send sends e-mail.

type Config

type Config struct {
	Host        string `env:"MG_EMAIL_HOST"         envDefault:"localhost"`
	Port        string `env:"MG_EMAIL_PORT"         envDefault:"25"`
	Username    string `env:"MG_EMAIL_USERNAME"     envDefault:"root"`
	Password    string `env:"MG_EMAIL_PASSWORD"     envDefault:""`
	FromAddress string `env:"MG_EMAIL_FROM_ADDRESS" envDefault:""`
	FromName    string `env:"MG_EMAIL_FROM_NAME"    envDefault:""`
	Template    string `env:"MG_EMAIL_TEMPLATE"     envDefault:"email.tmpl"`
}

Config email agent configuration.

Jump to

Keyboard shortcuts

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