smtpServer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT-0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COMMAND_HELO = CommandName("HELO")
	COMMAND_EHLO = CommandName("EHLO")
	COMMAND_AUTH = CommandName("AUTH")
	COMMAND_MAIL = CommandName("MAIL")
	COMMAND_RCPT = CommandName("RCPT")
	COMMAND_DATA = CommandName("DATA")
	COMMAND_QUIT = CommandName("QUIT")
)
View Source
const (
	STATE_CONVERSATION = ConversationState("conversation")
	STATE_WAITING_AUTH = ConversationState("waiting_auth")
	STATE_DATA         = ConversationState("data")
	STATE_CUSTOM_SCENE = ConversationState("custom_scene")
)
View Source
const (
	CODE_SYSTEM_STATUS             = 211
	CODE_HELP_MESSAGE              = 214
	CODE_SERVICE_READY             = 220
	CODE_SERVICE_CLOSING           = 221
	CODE_AUTHENTICATION_SUCCESS    = 235
	CODE_ACTION_OK                 = 250
	CODE_USER_IS_NOT_LOCAL         = 251 // will forward to <forward-path>
	CODE_USER_NOT_VERIFIED         = 252
	CODE_AUTH_CREDENTIALS          = 334
	CODE_MAIL_DATA                 = 354
	CODE_SERVICE_NOT_AVAILABLE     = 421
	CODE_MAILBOX_UNAVAILABLE       = 450
	CODE_LOCAL_ERROR               = 451
	CODE_EXCEEDED_SYSTEM_STORAGE   = 452
	CODE_COMMAND_SYNTAX_ERROR      = 500
	CODE_PARAMETER_SYNTAX_ERROR    = 501
	CODE_COMMAND_NOT_IMPLEMENTED   = 502
	CODE_COMMANDS_BAD_SEQUENCE     = 503
	CODE_PARAMETER_NOT_IMPLEMENTED = 504
	CODE_AUTH_FAILED               = 535
	CODE_MAILBOX_404               = 550
	CODE_USER_NOT_LOCAL            = 551 // please try <forward-path>
	CODE_EXCEEDED_STORAGE          = 552
	CODE__MAILBOX_NAME_INCORRECT   = 553
	CODE_TRANSACTION_FAILED        = 554
)
View Source
const COMMAND_END_SYMBOL = "\r\n"

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

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

Command is a struct representing an SMTP command (verb + arguments)

func CommandFromLine

func CommandFromLine(line string) *Command

type CommandName

type CommandName string

type ConversationState

type ConversationState string

type Protocol

type Protocol struct {
	Hostname string

	State   ConversationState
	Message *dto.SMTPMessage

	AuthenticationMechanismsCallback func() []string
	MessageReceivedCallback          func(message *dto.SMTPMessage) (string, error)

	CreateCustomSceneCallback func(sceneName string) Scene
	// contains filtered or unexported fields
}

func CreateProtocol

func CreateProtocol(hostname string, validation *Validation) *Protocol

func (*Protocol) EHLO

func (protocol *Protocol) EHLO(command *Command) *Reply

func (*Protocol) HELO

func (protocol *Protocol) HELO(command *Command) *Reply

func (*Protocol) HandleReceivedLine

func (protocol *Protocol) HandleReceivedLine(receivedLine string) *Reply

func (*Protocol) MAIL

func (protocol *Protocol) MAIL(command *Command) *Reply

func (*Protocol) ParseFROM

func (protocol *Protocol) ParseFROM(mail string) (string, error)

func (*Protocol) ParseRCPT

func (protocol *Protocol) ParseRCPT(mail string) (string, error)

func (*Protocol) RCPT

func (protocol *Protocol) RCPT(command *Command) *Reply

func (*Protocol) SayHi

func (protocol *Protocol) SayHi(identification string) *Reply

type Reply

type Reply struct {
	Status int
	// contains filtered or unexported fields
}

Reply is a struct representing an SMTP reply (status code + lines)

func ReplyAuthCredentials

func ReplyAuthCredentials(response string) *Reply

ReplyAuthCredentials creates reply with a 334 code and requests a username

func ReplyAuthFailed

func ReplyAuthFailed() *Reply

ReplyAuthFailed creates reply with auth failed response

func ReplyAuthOk

func ReplyAuthOk() *Reply

ReplyAuthOk creates a authentication successful reply

func ReplyBye

func ReplyBye() *Reply

func ReplyCommandNotImplemented

func ReplyCommandNotImplemented() *Reply

func ReplyExceededStorage

func ReplyExceededStorage(response string) *Reply

func ReplyLineTooLong

func ReplyLineTooLong() *Reply

ReplyLineTooLong due to exceeding these limits

func ReplyMailData

func ReplyMailData() *Reply

func ReplyMailbox404

func ReplyMailbox404(response string) *Reply

func ReplyOk

func ReplyOk(message ...string) *Reply

func ReplyServiceReady

func ReplyServiceReady(identification string) *Reply

ReplyServiceReady creates a welcome reply

func ReplyUnrecognisedCommand

func ReplyUnrecognisedCommand() *Reply

func (Reply) Lines

func (r Reply) Lines() []string

Lines returns the formatted SMTP reply

type Scene

type Scene interface {
	Init(receivedLine string, protocol *Protocol) *Reply
	HandleLine(receivedLine string) *Reply
}

type Validation

type Validation struct {
	MaximumLineLength int
	MaximumReceivers  int
}

Jump to

Keyboard shortcuts

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