email

package
v0.0.0-...-b12c321 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Send basic messages over SMTP

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mail

type Mail struct {
	Server   string   `env:"MAIL_SERVER"`              // SMTP server (mandatory)
	TLS      bool     `env:"MAIL_TLS"`                 // Enable TLS connection
	Login    string   `env:"MAIL_LOGIN"`               // Login name and sender email (mandatory)
	Password string   `env:"MAIL_PASSWORD"`            // Send password (if no password defined, AUTH will not be used)
	To       []string `env:"MAIL_TO" envSeparator:":"` // Default receivers
}

Mail configuration

func Default

func Default() *Mail

Default mail configuration from env variables

MAIL_SERVER - mandatory, address with port (usually: 25 for non-TLS, 465 for TLS) of SMTP server
MAIL_LOGIN  - mandatory, login/sender email address

func (Mail) SendContext

func (mail Mail) SendContext(ctx context.Context, data []byte, subject, contentType string, to []string) error

Send arbitrary content over SMTP server. Addresses will be visible in To header

func (Mail) SendText

func (mail Mail) SendText(subject, text string) error

Send plain/text message to default addresses (see SendTextToContext)

func (Mail) SendTextContext

func (mail Mail) SendTextContext(ctx context.Context, subject, text string) error

Send plain/text message to default addresses (see SendTextToContext)

func (Mail) SendTextTo

func (mail Mail) SendTextTo(subject, text string, to []string) error

Send plain/text message to custom addresses (see SendTextToContext)

func (Mail) SendTextToContext

func (mail Mail) SendTextToContext(ctx context.Context, subject, text string, to []string) error

Send plain/text message to custom addresses. Addresses will be visible in To header

Jump to

Keyboard shortcuts

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