Help us shape the future of Go! Take the 2026 Go Developer Survey

sender

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 4 Imported by: 0

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 {
	EmailParams
	logger.L
	// contains filtered or unexported fields
}

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

func NewEmailClient

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

NewEmailClient creates email client

func (*Email) Send

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

Send email with given text, with no cancellation and with TimeOut applied to the connection setup only. See SendContext for the details.

func (*Email) SendContext added in v1.26.0

func (e *Email) SendContext(ctx context.Context, to, text string) error

SendContext sends email with given text and terminates the whole SMTP transaction as soon as ctx is done. TimeOut covers the connection setup only, so without a context a server accepting the connection and stalling afterwards blocks the caller for as long as it likes.

The body is not logged: confirmation emails sent by the verify provider contain a one-shot magic-link token, and any party with log access could redeem it before the user does. Logging only the recipient and body length keeps the line useful for operators without leaking the credential.

type EmailParams

type EmailParams struct {
	Host        string // SMTP host
	Port        int    // SMTP port
	HELOHost    string // SMTP HELO/EHLO hostname, defaults to localhost when unset
	From        string // from email field
	Subject     string // email subject
	ContentType string // content type

	TLS                bool          // TLS auth
	StartTLS           bool          // startTLS auth
	InsecureSkipVerify bool          // skip certificate verification
	Charset            string        // character set
	LoginAuth          bool          // LOGIN auth method instead of default PLAIN, needed for Office 365 and outlook.com
	SMTPUserName       string        // username
	SMTPPassword       string        // password
	TimeOut            time.Duration // TCP connection timeout
}

EmailParams with all needed to make new Email client with smtp

Jump to

Keyboard shortcuts

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