smtp

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT-0 Imports: 12 Imported by: 0

README

SMTP server

Has very simple

// Start server
go smtp.Listen(context, exitChannel)
// And close on demand (by default it will ve closed on close application)
smtp.Close()

All required data an configuration goes through context variable

Documentation

Index

Constants

View Source
const (
	AuthMechanismPlain = "PLAIN"
)

Variables

This section is empty.

Functions

func Close added in v1.0.15

func Close() error

Close listener

func Listen

func Listen(context *serverContext.Context, exitCh chan int)

Listen "client" welcome message to initialise session (protocol). Start server

Types

type AuthPlainScene

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

func (*AuthPlainScene) Finish added in v1.0.15

func (scene *AuthPlainScene) Finish()

func (*AuthPlainScene) ReadAndWriteReply added in v1.0.15

func (scene *AuthPlainScene) ReadAndWriteReply(receivedLine string) *smtpServerProtocol.Reply

func (*AuthPlainScene) Start added in v1.0.15

func (scene *AuthPlainScene) Start(receivedLine string, protocol *smtpServerProtocol.Protocol) *smtpServerProtocol.Reply

type Protocol added in v1.0.15

type Protocol interface {
	// SetAuthMechanisms sets allowed by app auth mechanisms
	// if empty then no auth check need.
	SetAuthMechanisms(authMechanisms []string)
	// SayWelcome starts conversation with "client"
	SayWelcome(identification string) *smtpServerProtocol.Reply
	// HandleReceivedLine receive sent client message line by line
	// handle it and returns reply.
	HandleReceivedLine(receivedLine string) *smtpServerProtocol.Reply
	// CreateCustomSceneUsing - for some commands, methods good to have logic code in this top level
	// package than in protocol, like authentication code, etc. And there scenes are useful.
	CreateCustomSceneUsing(callback func(sceneName string) smtpServerProtocol.Scene)
	// SetStateCommandsExchange notify protocol to exit custom scene back to commands exchange
	SetStateCommandsExchange()
	// OnMessageReceived function called only when smtp protocol finished and messaage fully received and processed.
	// So package can save this message or send to other services and return string ID of saved message to send
	// this ID to "client"
	OnMessageReceived(callback func(message *smtpMessage.SmtpMessage) (string, error))
}

Protocol interface describe all methods what use server. Used to add possibility override/inherit current protocol

Jump to

Keyboard shortcuts

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