mail

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

A WordDecoder decodes MIME headers containing RFC 2047 encoded-words. Used by the MimeHeaderDecode function. It's exposed public so that an alternative decoder can be set, eg Gnu iconv by importing the mail/inconv package. Another alternative would be to use https://godoc.org/golang.org/x/text/encoding

Functions

func MimeHeaderDecode

func MimeHeaderDecode(str string) string

MimeHeaderDecode converts 7 bit encoded mime header strings to UTF-8

Types

type Address

type Address struct {
	// User is local part
	User string
	// Host is the domain
	Host string
	// ADL is at-domain list if matched
	ADL []string
	// PathParams contains any ESTMP parameters that were matched
	PathParams [][]string
	// NullPath is true if <> was received
	NullPath bool
	// Quoted indicates if the local-part needs quotes
	Quoted bool
	// IP stores the IP Address, if the Host is an IP
	IP net.IP
	// DisplayName is a label before the address (RFC5322)
	DisplayName string
	// DisplayNameQuoted is true when DisplayName was quoted
	DisplayNameQuoted bool
}

Address encodes an email address of the form `<user@host>`

func NewAddress

func NewAddress(str string) (*Address, error)

NewAddress takes a string of an RFC 5322 address of the form "Gogh Fir <gf@example.com>" or "foo@example.com".

func (*Address) IsEmpty

func (a *Address) IsEmpty() bool

func (*Address) IsPostmaster

func (a *Address) IsPostmaster() bool

func (*Address) String

func (a *Address) String() string

type Envelope

type Envelope struct {
	// Remote IP address
	RemoteIP string
	// Message sent in EHLO command
	Helo string
	// Sender
	MailFrom Address
	// Recipients
	RcptTo []Address
	// Data stores the header and message body
	Data bytes.Buffer
	// Subject stores the subject of the email, extracted and decoded after calling ParseHeaders()
	Subject string
	// TLS is true if the email was received using a TLS connection
	TLS bool
	// Header stores the results from ParseHeaders()
	Header textproto.MIMEHeader
	// Values hold the values generated when processing the envelope by the backend
	Values map[string]interface{}
	// Hashes of each email on the rcpt
	Hashes []string
	// additional delivery header that may be added
	DeliveryHeader string
	// Email(s) will be queued with this id
	QueuedId string
	// ESMTP: true if EHLO was used
	ESMTP bool
	// When locked, it means that the envelope is being processed by the backend
	sync.Mutex
}

Envelope of Email represents a single SMTP message.

func NewEnvelope

func NewEnvelope(remoteAddr string, clientID uint64) *Envelope

func (*Envelope) Len

func (e *Envelope) Len() int

Len returns the number of bytes that would be in the reader returned by NewReader()

func (*Envelope) NewReader

func (e *Envelope) NewReader() io.Reader

NewReader returns a new reader for reading the email contents, including the delivery headers

func (*Envelope) ParseHeaders

func (e *Envelope) ParseHeaders() error

ParseHeaders parses the headers into Header field of the Envelope struct. Data buffer must be full before calling. It assumes that at most 30kb of email data can be a header Decoding of encoding to UTF is only done on the Subject, where the result is assigned to the Subject field

func (*Envelope) PopRcpt

func (e *Envelope) PopRcpt() Address

PopRcpt removes the last email address that was pushed to the envelope

func (*Envelope) PushRcpt

func (e *Envelope) PushRcpt(addr Address)

PushRcpt adds a recipient email address to the envelope

func (*Envelope) Reseed

func (e *Envelope) Reseed(remoteIP string, clientID uint64)

Reseed is called when used with a new connection, once it's accepted

func (*Envelope) ResetTransaction

func (e *Envelope) ResetTransaction()

ResetTransaction is called when the transaction is reset (keeping the connection open)

func (*Envelope) String

func (e *Envelope) String() string

String converts the email to string. Typically, you would want to use the compressor guerrilla.Processor for more efficiency, or use NewReader

type Pool

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

func NewPool

func NewPool(poolSize int) *Pool

func (*Pool) Borrow

func (p *Pool) Borrow(remoteAddr string, clientID uint64) *Envelope

func (*Pool) Return

func (p *Pool) Return(e *Envelope)

Return returns an envelope back to the envelope pool Make sure that envelope finished processing before calling this

Directories

Path Synopsis
iconv enables using GNU iconv for converting 7bit to UTF-8.
iconv enables using GNU iconv for converting 7bit to UTF-8.

Jump to

Keyboard shortcuts

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