sender

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package sender provides email sender

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	logger.L
	SMTPClient
	EmailParams
}

Email implements sender interface for VerifyHandler Uses common subject line and "from" for all messages

func NewEmailClient

func NewEmailClient(p EmailParams, l logger.L) *Email

NewEmailClient creates email client with prepared smtp

func (*Email) Send

func (em *Email) Send(to, text string) error

Send email with given text If SMTPClient defined in Email struct it will be used, if not - new smtp.Client on each send. Always closes client on completion or failure.

type EmailParams

type EmailParams struct {
	Host        string // SMTP host
	Port        int    // SMTP port
	From        string // From email field
	Subject     string // Email subject
	ContentType string // Content type, optional. Will trigger MIME and Content-Type headers

	TLS          bool   // TLS auth
	SMTPUserName string // user name
	SMTPPassword string // password
	TimeOut      time.Duration
}

EmailParams with all needed to make new Email client with smtp

type SMTPClient

type SMTPClient interface {
	Mail(string) error
	Auth(smtp.Auth) error
	Rcpt(string) error
	Data() (io.WriteCloser, error)
	Quit() error
	Close() error
}

SMTPClient interface defines subset of net/smtp used by email client

Jump to

Keyboard shortcuts

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