go-smtpsrv: github.com/alash3al/go-smtpsrv Index | Files

package smtpsrv

import "github.com/alash3al/go-smtpsrv"

Index

Package Files

backend.go context.go errors.go handlers.go helpers.go parser.go server.go session.go spf_result.go

Variables

var (
    ErrAuthDisabled = errors.New("auth is disabled")
)

func ListenAndServe Uses

func ListenAndServe(cfg *ServerConfig) error

func ListenAndServeTLS Uses

func ListenAndServeTLS(cfg *ServerConfig) error

func SetDefaultServerConfig Uses

func SetDefaultServerConfig(cfg *ServerConfig)

func SplitAddress Uses

func SplitAddress(address string) (string, string, error)

SplitAddress split the email@addre.ss to <user>@<domain>

type Attachment Uses

type Attachment struct {
    Filename    string
    ContentType string
    Data        io.Reader
}

Attachment with filename, content type and data (as a io.Reader)

type AuthFunc Uses

type AuthFunc func(username, password string) error

type Backend Uses

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

The Backend implements SMTP server methods.

func NewBackend Uses

func NewBackend(auther AuthFunc, handler HandlerFunc) *Backend

func (*Backend) AnonymousLogin Uses

func (bkd *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error)

AnonymousLogin requires clients to authenticate using SMTP AUTH before sending emails

func (*Backend) Login Uses

func (bkd *Backend) Login(state *smtp.ConnectionState, username, password string) (smtp.Session, error)

Login handles a login command with username and password.

type Context Uses

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

func (Context) From Uses

func (c Context) From() *mail.Address

func (Context) Mailable Uses

func (c Context) Mailable() (bool, error)

func (Context) Parse Uses

func (c Context) Parse() (*Email, error)

func (Context) Read Uses

func (c Context) Read(p []byte) (int, error)

func (Context) RemoteAddr Uses

func (c Context) RemoteAddr() net.Addr

func (Context) SPF Uses

func (c Context) SPF() (SPFResult, string, error)

func (Context) TLS Uses

func (c Context) TLS() *tls.ConnectionState

func (Context) To Uses

func (c Context) To() *mail.Address

func (Context) User Uses

func (c Context) User() (string, string, error)

type Email Uses

type Email struct {
    Header mail.Header

    Subject    string
    Sender     *mail.Address
    From       []*mail.Address
    ReplyTo    []*mail.Address
    To         []*mail.Address
    Cc         []*mail.Address
    Bcc        []*mail.Address
    Date       time.Time
    MessageID  string
    InReplyTo  []string
    References []string

    ResentFrom      []*mail.Address
    ResentSender    *mail.Address
    ResentTo        []*mail.Address
    ResentDate      time.Time
    ResentCc        []*mail.Address
    ResentBcc       []*mail.Address
    ResentMessageID string

    ContentType string
    Content     io.Reader

    HTMLBody string
    TextBody string

    Attachments   []Attachment
    EmbeddedFiles []EmbeddedFile
}

Email with fields for all the headers defined in RFC5322 with it's attachments and

func ParseEmail Uses

func ParseEmail(r io.Reader) (email *Email, err error)

Parse an email message read from io.Reader into parsemail.Email struct

type EmbeddedFile Uses

type EmbeddedFile struct {
    CID         string
    ContentType string
    Data        io.Reader
}

EmbeddedFile with content id, content type and data (as a io.Reader)

type HandlerFunc Uses

type HandlerFunc func(*Context) error

type SPFResult Uses

type SPFResult = spf.Result

type ServerConfig Uses

type ServerConfig struct {
    ListenAddr      string
    BannerDomain    string
    ReadTimeout     time.Duration
    WriteTimeout    time.Duration
    Handler         HandlerFunc
    Auther          AuthFunc
    MaxMessageBytes int
    TLSConfig       *tls.Config
}

type Session Uses

type Session struct {
    From *mail.Address
    To   *mail.Address
    // contains filtered or unexported fields
}

A Session is returned after successful login.

func NewSession Uses

func NewSession(state *smtp.ConnectionState, handler HandlerFunc, username, password *string) *Session

NewSession initialize a new session

func (*Session) Data Uses

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

func (*Session) Logout Uses

func (s *Session) Logout() error

func (*Session) Mail Uses

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

func (*Session) Rcpt Uses

func (s *Session) Rcpt(to string) (err error)

func (*Session) Reset Uses

func (s *Session) Reset()

Package smtpsrv imports 16 packages (graph) and is imported by 2 packages. Updated 2020-06-19. Refresh now. Tools for package owners.