mail

package
v0.0.0-...-8d83eef Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MailTransportDecode

func MailTransportDecode(str string, encodingType string, charset string) string

decode from 7bit to 8bit UTF-8 encodingType can be "base64" or "quoted-printable"

func MimeHeaderDecode

func MimeHeaderDecode(str string) string

Decode strings in Mime header format eg. =?ISO-2022-JP?B?GyRCIVo9dztSOWJAOCVBJWMbKEI=?= This function uses GNU iconv under the hood, for more charset support than in Go's library

Types

type Address

type Address struct {
	User string
	Host string
}

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 (ep *Address) IsEmpty() bool

func (*Address) String

func (ep *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
	// When locked, it means that the envelope is being processed by the backend
	sync.Mutex
	// to determine user
	AuthorizedLogin string
}

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

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

Pop 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)

Seed 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 Note that an envelope will not be recycled while it still is processing

Jump to

Keyboard shortcuts

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