smtp

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 4 Imported by: 0

README

smtp v1

A Go package that provides a simple interface for sending emails via SMTP.

Installation

go get -u github.com/metadiv-io/smtp

Documentation

smtp v1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnvHost        = env.New("SMTP_HOST", false)
	EnvPort        = env.New("SMTP_PORT", false)
	EnvUsername    = env.New("SMTP_USERNAME", false)
	EnvPassword    = env.New("SMTP_PASSWORD", false)
	EnvDisplayName = env.New("SMTP_DISPLAY_NAME", false)
)

Functions

func EmailList

func EmailList(emails ...string) []string

EmailList returns a list of emails.

Types

type Dialer

type Dialer struct {
	DisplayName string `json:"display_name"`
	Host        string `json:"host"`
	Port        int    `json:"port"`
	Username    string `json:"username"`
	Password    string `json:"password"`
}

Dialer is a SMTP dialer.

func NewDefaultDialer

func NewDefaultDialer() *Dialer

NewDefaultDialer creates a new SMTP dialer with the default environment variables.

func NewDialer

func NewDialer(displayName, host string, port int, username, password string) *Dialer

NewDialer creates a new SMTP dialer.

func (*Dialer) SendHTMLEmail

func (d *Dialer) SendHTMLEmail(to, cc, bcc []string, subject, body string, valuesMap ...map[string]string) error

SendHTMLEmail sends an HTML email. valuesMap is a map of key-value pairs that will be used to replace the placeholders in the subject and body.

func (*Dialer) SendTextEmail

func (d *Dialer) SendTextEmail(to, cc, bcc []string, subject, body string, valuesMap ...map[string]string) error

SendTextEmail sends a text email. valuesMap is a map of key-value pairs that will be used to replace the placeholders in the subject and body.

Jump to

Keyboard shortcuts

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