Documentation
¶
Index ¶
- Constants
- type Command
- type CommandName
- type ConversationState
- type Protocol
- func (protocol *Protocol) CreateCustomSceneUsing(callback func(sceneName string) Scene)
- func (protocol *Protocol) EHLO(command *Command) *Reply
- func (protocol *Protocol) HELO(command *Command) *Reply
- func (protocol *Protocol) HandleReceivedLine(receivedLine string) *Reply
- func (protocol *Protocol) MAIL(command *Command) *Reply
- func (protocol *Protocol) OnMessageReceived(callback func(message *smtpMessage.SmtpMessage) (string, error))
- func (protocol *Protocol) RCPT(command *Command) *Reply
- func (protocol *Protocol) RSET(command *Command) *Reply
- func (protocol *Protocol) SayWelcome(identification string) *Reply
- func (protocol *Protocol) SetAuthMechanisms(authMechanisms []string)
- func (protocol *Protocol) SetStateCommandsExchange()
- type Reply
- func ReplyAuthCredentials(response string) *Reply
- func ReplyAuthFailed(response string) *Reply
- func ReplyAuthOk() *Reply
- func ReplyBye() *Reply
- func ReplyCommandNotImplemented() *Reply
- func ReplyExceededStorage(response string) *Reply
- func ReplyLineTooLong() *Reply
- func ReplyMailData() *Reply
- func ReplyMailbox404(response string) *Reply
- func ReplyOk(message ...string) *Reply
- func ReplyServiceReady(identification string) *Reply
- func ReplyUnrecognisedCommand() *Reply
- type Scene
- type Validation
Constants ¶
const ( CommandHelo = CommandName("HELO") CommandEhlo = CommandName("EHLO") CommandAuth = CommandName("AUTH") CommandMail = CommandName("MAIL") CommandRset = CommandName("RSET") CommandRcpt = CommandName("RCPT") CommandData = CommandName("DATA") CommandQuit = CommandName("QUIT") )
List predefined command names
const ( StateCommandsExchange = ConversationState("commands_exchange") StateWaitingAuth = ConversationState("waiting_auth") StateData = ConversationState("data") StateCustomScene = ConversationState("custom_scene") )
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 )
LIst of predefined by rfc5321 list of status codes.
const CommandEndSymbol = "\r\n"
CommandEndSymbol contains separator to understand where command is ended and need generate reply.
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 ¶
CommandFromLine creates Command object form line string
type CommandName ¶
type CommandName string
CommandName represent standard command name (sting) described in rfc5321
type ConversationState ¶
type ConversationState string
ConversationState represents on what stage now current Client<->Server conversation.
type Protocol ¶
Protocol represents rfc5321 described protocol conversation
func CreateProtocol ¶
func CreateProtocol(hostname string, ip *net.TCPAddr, validation *Validation) *Protocol
func (*Protocol) CreateCustomSceneUsing ¶
func (*Protocol) HandleReceivedLine ¶
func (*Protocol) OnMessageReceived ¶
func (protocol *Protocol) OnMessageReceived(callback func(message *smtpMessage.SmtpMessage) (string, error))
OnMessageReceived allow to provide custom success callback.
func (*Protocol) SayWelcome ¶
func (*Protocol) SetAuthMechanisms ¶
func (*Protocol) SetStateCommandsExchange ¶
func (protocol *Protocol) SetStateCommandsExchange()
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 ¶
ReplyAuthCredentials creates reply with a 334 code and requests a username
func ReplyAuthFailed ¶
func ReplyCommandNotImplemented ¶
func ReplyCommandNotImplemented() *Reply
func ReplyExceededStorage ¶
func ReplyLineTooLong ¶
func ReplyLineTooLong() *Reply
ReplyLineTooLong due to exceeding these limits
func ReplyMailData ¶
func ReplyMailData() *Reply
func ReplyMailbox404 ¶
func ReplyServiceReady ¶
ReplyServiceReady creates a welcome reply.
func ReplyUnrecognisedCommand ¶
func ReplyUnrecognisedCommand() *Reply
func (Reply) FormattedLines ¶
FormattedLines returns the formatted SMTP reply lines.
type Scene ¶
type Scene interface { // Start scene by send specific message (reply) to client. Start(receivedLine string, protocol *Protocol) *Reply // ReadAndWriteReply reads client message and write reply ReadAndWriteReply(receivedLine string) *Reply // Finish scene, by notifying protocol to finish this scene Finish() }
Scene represents custom logic flow (scene) for some specific set of commands, for example authentication.
type Validation ¶
Validation allows to send to package custom validation parameters what accepts server