smtptarget

package module
v0.0.0-...-2d87e10 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package smtptarget offers a replacement for common uses of smtp.SendMail() with support for persistent connections. In the name of simplicity it only supports plain auth protected by TLS. It is thread safe, but operations will not be executed in parallell.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Target

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

Target represents a destination to which mail may be sent

func New

func New(addr, username, password string, timeout time.Duration) *Target

New creates a new Target to which you can send mail. host should be a host and port in the format "smtp.example.com:587". Username and password are required. Anonymous authentication is not supported. timeout is how long the connection will be allowed to sit idle before it is disconnected. It will automatically re-connect next time you call SendMail().

func (*Target) Close

func (t *Target) Close() error

Close the connection to the SMTP server and end the possibleTimeout watcher thread. The Target cannot be used after this. You must make a new one.

func (*Target) EnableKeyLog

func (t *Target) EnableKeyLog(filename string) (err error)

EnableKeyLog will start writing TLS secrets to a file. See: https://wiki.wireshark.org/TLS#Using_the_.28Pre.29-Master-Secret

func (*Target) SendMail

func (t *Target) SendMail(from string, to []string, msg []byte) error

SendMail works like smtp.SendMail() except that it uses the connection from the Target. It will first re-establish the connection if the connection is unhealthy or not connected.

Jump to

Keyboard shortcuts

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