src

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartEmailServer

func StartEmailServer(opts StartEmailServerOptions)

StartEmailServer starts the email server

func StartWebserver

func StartWebserver(dist embed.FS, opts StartWebserverOptions)

StartWebserver starts the webserver

Types

type Address

type Address struct {
	Name    string `json:"name"`
	Address string `json:"address"`
}

Address with json attributes

func ConvertAddress

func ConvertAddress(ad mail.Address) Address

ConvertAddress converts mail.Address to a Address

func ConvertAddressList

func ConvertAddressList(adList []*mail.Address) []*Address

ConvertAddressList converts a list of mail.Address to a list of Address

func MightConvertAddress

func MightConvertAddress(ad *mail.Address) *Address

MightConvertAddress converts *mail.Address to a *Address

type Attachment

type Attachment struct {
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Data        []byte `json:"-"`
}

Attachment with json attributes

func ConvertAttachment

func ConvertAttachment(at parsemail.Attachment) (Attachment, error)

ConvertAttachment converts parsemail.Attachment to a Attachment

func ConvertAttachmentList

func ConvertAttachmentList(atList []parsemail.Attachment) ([]Attachment, error)

ConvertAttachmentList converts a list of parsemail.Attachment to a list of Attachment

type Backend

type Backend struct {
	Credentials *EmailCredentials
	Entropy     *rand.Rand
	MaxEmails   int
}

The Backend implements SMTP server methods.

func (*Backend) NewSession

func (b *Backend) NewSession(_ *smtp.Conn) (smtp.Session, error)

NewSession implements smtp.Backend

type Email

type Email struct {
	// Added by our server
	ID       ulid.ULID `json:"id"`
	RealDate time.Time `json:"realDate"`
	Subject  string    `json:"subject"`
	BodyType string    `json:"bodyType"` // "html" or "text"
	BodyHint string    `json:"bodyHint"`

	// Recived form the client
	Sender *Address   `json:"sender"`
	From   []*Address `json:"from"`
	To     []*Address `json:"to"`

	Remainder EmailRemainder `json:"-"`
}

Email contains a single email

func ConvertEmail

func ConvertEmail(ulid ulid.ULID, emlRawData []byte, em parsemail.Email, realDate time.Time, realFrom, realTo string) (Email, error)

ConvertEmail converts parsemail.Email to a Email

type EmailCredentials

type EmailCredentials struct {
	Username string
	Password string
}

type EmailRemainder

type EmailRemainder struct {
	Raw string `json:"raw"`

	Header mail.Header `json:"header"`

	ReplyTo    []*Address `json:"replyTo"`
	Cc         []*Address `json:"cc"`
	Bcc        []*Address `json:"bcc"`
	Date       time.Time  `json:"date"`
	MessageID  string     `json:"messageId"`
	InReplyTo  []string   `json:"inReplyTo"`
	References []string   `json:"references"`

	ResentFrom      []*Address `json:"resentFrom"`
	ResentSender    *Address   `json:"resentSender"`
	ResentTo        []*Address `json:"resentTo"`
	ResentDate      time.Time  `json:"resentDate"`
	ResentCc        []*Address `json:"resentCc"`
	ResentBcc       []*Address `json:"resentBcc"`
	ResentMessageID string     `json:"resentMessageId"`

	ContentType string `json:"contentType"`

	HTMLBody string `json:"htmlBody"`
	TextBody string `json:"textBody"`

	Attachments   []Attachment   `json:"attachments"`
	EmbeddedFiles []EmbeddedFile `json:"embeddedFiles"`
}

type EmbeddedFile

type EmbeddedFile struct {
	M *sync.Mutex `json:"-"`

	CID         string `json:"cid"`
	ContentType string `json:"contentType"`
	Data        []byte `json:"-"`
}

EmbeddedFile with json attributes

func ConvertEmbeddedFile

func ConvertEmbeddedFile(eb parsemail.EmbeddedFile) (EmbeddedFile, error)

ConvertEmbeddedFile converts parsemail.EmbeddedFile to a EmbeddedFile

func ConvertEmbeddedFileList

func ConvertEmbeddedFileList(ebList []parsemail.EmbeddedFile) ([]EmbeddedFile, error)

ConvertEmbeddedFileList converts a list of parsemail.EmbeddedFile to a list of EmbeddedFile

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse is the response send by the server when an error occurs

type Session

type Session struct {
	Backend *Backend
	From    string
	To      string
	Auth    bool
}

A Session is returned after EHLO.

func (*Session) AuthPlain

func (s *Session) AuthPlain(username, password string) error

AuthPlain implements smtp.Session

func (*Session) Data

func (s *Session) Data(r io.Reader) error

Data implements smtp.Session

func (*Session) Logout

func (s *Session) Logout() error

Logout implements smtp.Session

func (*Session) Mail

func (s *Session) Mail(from string, opts *smtp.MailOptions) error

Mail implements smtp.Session

func (*Session) Rcpt

func (s *Session) Rcpt(to string, opts *smtp.RcptOptions) error

Rcpt implements smtp.Session

func (*Session) Reset

func (s *Session) Reset()

Reset implements smtp.Session

type StartEmailServerOptions

type StartEmailServerOptions struct {
	Addr      string
	Domain    string
	Username  string
	Password  string
	MaxEmails uint16
}

StartEmailServerOptions are the options for starting the email server

type StartWebserverOptions

type StartWebserverOptions struct {
	Addr              string
	BasicAuthUsername string
	BasicAuthPassword string
}

StartWebserverOptions are the options for the webserver

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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