Documentation ¶
Overview ¶
Package mail implements a mail server, client and various other bits and bobs.
Index ¶
Constants ¶
const ( // OutCapacity is the capacity of the output queue. OutCapacity = 250 // OutCapacityMargin is the additional margin to keep in the output queue. // This margin avoids the output queue becoming blocked // when multiple messages arrive simultaneously. OutCapacityMargin = 50 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct { GetList ListRetriever Directory string HandleFunc *MessageHandler }
Backend contains the backend implementation for the mail server. It implements smtp.Backend.
func (*Backend) AnonymousLogin ¶
AnonymousLogin requires clients to authenticate using SMTP AUTH before sending emails.
type Client ¶
type Client struct { SMTPServer string // contains filtered or unexported fields }
Client represents an SMTP client.
func (*Client) Disconnect ¶
Disconnect disconnects from the email server.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(msg *SingleMessage) (err error)
SendMessage sends an email message
func (*Client) Worker ¶
func (c *Client) Worker(ch chan *SingleMessage) (err error)
Worker sends emails that are placed in a channel. It automatically connects and disconnects to
type Config ¶
type Config struct { // Address is the address to listen on. Address string `yaml:"address"` // Domain is the domain of this mail server. Domain string `yaml:"domain"` // SMTPServer contains the address the SMTP server to use for sending mail. SMTPServer string `yaml:"smtp_server"` // Directory is the directory used for storing received mails. Directory string `yaml:"directory"` }
Config contains the configuration of an SMTP server.
type ListRetriever ¶
ListRetriever represents a function that can be used to retrieve a mailing list.
type Message ¶
Message represents a single e-mail message on one or more mailing lists.
func MessageFromFile ¶
MessageFromFile opens and parses a message from a file.
func (*Message) SetBody ¶
SetBody sets the body of the message from an io.Reader. Headers are modified as needed.
func (*Message) SingleMessages ¶
func (m *Message) SingleMessages() (messages []*SingleMessage)
SingleMessages returns a set of single messages corresponding to this message.
func (*Message) WriteRaw ¶
WriteRaw writes the current message to an io.Writer. Nothing is modified.
func (*Message) WriteToFile ¶
WriteToFile writes the message to a given file.
type MessageHandler ¶
MessageHandler is a function that handles a message.
type Recipient ¶
type Recipient struct {
Name, Address string
}
Recipient contains an email recipient
type Server ¶
type Server struct { *smtp.Server Client *Client OutQueue chan *SingleMessage HandleFunc MessageHandler // contains filtered or unexported fields }
Server is an SMTP server.
func NewServer ¶
func NewServer(config *Config, listFunc ListRetriever) (*Server, error)
NewServer creates a new SMTP server.
func (*Server) HandleMessage ¶
HandleMessage handles an incoming message from the queue or some external component.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the network address s.Addr and serves incoming connections. Incoming messages are automatically added to OutQueue.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session contains the sessions information for a connection. It implements smtp.Session.
type SingleMessage ¶
SingleMessage is an email/list/recipient link. Recipient can be `nil`.