lib

package
v0.0.0-...-488c5b3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialFromList

func DialFromList(hosts []string, cfg *Config) (*smtp.Client, string)

DialFromList tries dialing in order a list of IPs as if they are email servers until exhausting possibilities.

func FindServers

func FindServers(domain string) []string

FindServers resolves the IP addresses of a given destination `domain`

func InterpretLog

func InterpretLog(l string, parsed *ParsedMessage)

InterpretLog matches the output of a `sendmail` command for a given ParsedMessage. Output lines indicating the message was delivered are used to remove remaining recipients where redelivery is needed.

func ParseDiskInput

func ParseDiskInput(filename string) ([]byte, error)

ParseDiskInput reads a filename, transforming the data with a configured 'ReadFromDisk' command if set. This allows messages to be passed through a gpg encryption process if desired.

func ReadMessage

func ReadMessage(reader io.Reader) []byte

ReadMessage scans a given io.Reader into a []byte.

func RemoveHeader

func RemoveHeader(msg *[]byte, header string)

RemoveHeader strips a single header from a byte array representing a full email message.

func SanitizeMessage

func SanitizeMessage(parsed ParsedMessage, cfg *Config) error

SanitizeMessage takes a byte buffer of an Email message, along with configuration for the sending domain, and uses these to transform the message into one that is more privacy preserving - in particular by quantizing identifying dates and message IDs. The byte buffer of the message is modified in-place.

func SignMessage

func SignMessage(parsed ParsedMessage, cfg *Config) error

SignMessage takes a message byte buffer, and adds a DKIM signature to it based on the configuration of the sending domain. the buffer is modified in place.

func StartTLS

func StartTLS(conn *smtp.Client, serverName string, cfg *Config, allowSelfSigned bool) error

StartTLS attempts to upgrade an SMTP network connection with StartTLS.

func WriteDiskOutput

func WriteDiskOutput(filename string, data []byte) error

WriteDiskOutput writes a bytestring to a desired file on disk, transforming the data through a configured `WriteToDisk` command if set. This allows messages to be passed through a gpg encryption process if desired.

Types

type Config

type Config struct {
	DkimKeyCmd   string
	DkimSelector string
	DialerProxy  string
	SourceHost   string
	TLSCert      string
	TLSKey       string

	SendCommand string
	// contains filtered or unexported fields
}

Config represents the structure of a single domain configuration in config.json

func GetConfig

func GetConfig(domain string) *Config

GetConfig looks for a domain in the currently loaded configuration and attempts to parse it as into a Config struct.

func (*Config) GetTLS

func (c *Config) GetTLS() *tls.Config

GetTLS returns a TLS configuration (the epxected certificate and server name) for a given configured domain.

type ParsedMessage

type ParsedMessage struct {
	Sender       string
	SourceDomain string
	Rcpt         map[string][]string
	DestDomain   []string
	Bytes        *[]byte
	*mail.Message
}

ParsedMessage represents a semi-structred email message.

func ParseMessage

func ParseMessage(msg *[]byte) ParsedMessage

ParseMessage parses a byte array representating an email message to learn the sender, and intended recipients.

func (ParsedMessage) FileName

func (p ParsedMessage) FileName() string

FileName provides a stable location on disk for the message to serialize to.

func (ParsedMessage) Hash

func (p ParsedMessage) Hash() string

Hash provides an ideally stable handle for a message.

func (ParsedMessage) MarshalText

func (p ParsedMessage) MarshalText() ([]byte, error)

MarshalText provides a textual handle of the message. The message contents is not included, and must be saved using `Save` for the marshal'ed handle to be considered durable.

func (*ParsedMessage) RecipientMap

func (p *ParsedMessage) RecipientMap() map[string]bool

RecipientMap returns a map for identification of recipients, where map keys are recipients and map values are `true`.

func (*ParsedMessage) Recipients

func (p *ParsedMessage) Recipients() string

Recipients gets a comma separated list (AddressList) of recipients.

func (*ParsedMessage) RemoveRecipients

func (p *ParsedMessage) RemoveRecipients(other string) error

RemoveRecipients updates the message.Recipients to no longer include a set of addresses specified in AddressList format.

func (*ParsedMessage) Save

func (p *ParsedMessage) Save() error

Save message to disk. TODO: support encryption of on-disk data.

func (*ParsedMessage) SetRecipients

func (p *ParsedMessage) SetRecipients(recipients string) error

SetRecipients sets the accounts and corresponding domains to which the email will be sent.

func (*ParsedMessage) SetSender

func (p *ParsedMessage) SetSender(sender string) error

SetSender specifies an explicit sending email account for the message.

func (p *ParsedMessage) Unlink() error

Unlink message data from disk if present.

func (*ParsedMessage) UnmarshalText

func (p *ParsedMessage) UnmarshalText(b []byte) error

UnmarshalText attempts to load a message from a textual pointer of its state.

Jump to

Keyboard shortcuts

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