websmtp

package
v0.0.0-...-4db3c8c Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindHost

func FindHost(addr string) string

FindHost looks for an email address' SMTP host by looking up DNS records and knocking on MX record entries. Returns empty string if not found.

Types

type SendRequest

type SendRequest struct {
	To      []string `json:"to" binding:"required"`
	Subject string   `json:"subject" binding:"required"`
	Body    string   `json:"body" binding:"required"`
}

SendRequest is a request to send an email to the specified 'to' addresses.

type SendStatus

type SendStatus struct {
	ID     string   `json:"id" binding:"required"`
	Status string   `json:"status" binding:"required"`
	Failed []string `json:"failed" binding:"required"`
}

SendStatus tracks the status of a SendRequest. If status is "completed", then Failed are the destination addresses that could not be reached. TODO: keep error messages on failed addresses.

type Sender

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

Sender maintains a queue of send requests and their status, and attempts to process them.

func NewSender

func NewSender(src string) *Sender

NewSender initializes a new sender with the given src string. Returns nil if src is an invalid email address.

func (*Sender) Enqueue

func (s *Sender) Enqueue(req SendRequest) string

Enqueue a request to the processing queue and return a reference ID.

func (*Sender) GetStatus

func (s *Sender) GetStatus(ref string) SendStatus

GetStatus returns the status of a request by looking up its reference ID.

func (*Sender) Run

func (s *Sender) Run()

Run begins processing the underlying send queue, one request at a time. It is meant to be ran as a goroutine. TODO: should take context as parameter, allow stopping, multiple threads.

Jump to

Keyboard shortcuts

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