smtpump

package
v0.0.0-...-40a457b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2014 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Connection handling part of an SMTP server for mailpump.

SMTP server implementation for mailpump.

Index

Constants

View Source
const (
	SMTP_STATUS                    = 211
	SMTP_HELP                      = 214
	SMTP_READY                     = 220
	SMTP_CLOSING                   = 221
	SMTP_COMPLETED                 = 250
	SMTP_NONLOCAL_USER             = 251
	SMTP_PROCEED                   = 354
	SMTP_UNAVAIL                   = 421
	SMTP_MAILBOX_UNAVAIL           = 450
	SMTP_LOCALERR                  = 451
	SMTP_SERVER_FULL               = 452
	SMTP_SYNTAX_ERROR              = 500
	SMTP_PARAMETER_ERROR           = 501
	SMTP_NOT_IMPLEMENTED           = 502
	SMTP_BAD_SEQUENCE              = 503
	SMTP_PARAMETER_NOT_IMPLEMENTED = 504
	SMTP_NONMAIL_DOMAIN            = 521
	SMTP_ACCESS_DENIED             = 530
	SMTP_BAD_AUTH                  = 535
	SMTP_NO_ACTION_MAILBOX_UNAVAIl = 550
	SMTP_PLEASE_FORWARD            = 551
	SMTP_MESSAGE_TOO_BIG           = 552
	SMTP_ILLEGAL_MAILBOX_NAME      = 553
	SMTP_TRANSACTION_FAILED        = 554
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SMTPServer

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

Structure to hold all data required for an active server.

func NewSMTPServer

func NewSMTPServer(netname, laddr string, callback SmtpReceiver) (
	*SMTPServer, error)

Create a new SMTP server listening on the address "laddr" with the protocol "net". Any callbacks will be done on "callback".

type SmtpConnection

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

An ongoing SMTP connection with all required state.

func (*SmtpConnection) GetDotReader

func (self *SmtpConnection) GetDotReader() io.Reader

Build and return a dotreader for the connection.

func (*SmtpConnection) GetUserdata

func (self *SmtpConnection) GetUserdata() interface{}

Retrieve the configured userdata for this connection.

func (*SmtpConnection) IsActive

func (self *SmtpConnection) IsActive() bool

Indicate to the caller whether the connection is still active.

func (*SmtpConnection) ReportBytesRead

func (self *SmtpConnection) ReportBytesRead(length int64)

Report the number of bytes read from the peer during the connection.

func (*SmtpConnection) ReportBytesWritten

func (self *SmtpConnection) ReportBytesWritten(length int64)

Report the number of bytes written to the peer during the connection.

func (*SmtpConnection) Respond

func (self *SmtpConnection) Respond(code int, continued bool, text string)

Send a message back to the client with the given SMTP response code and text.

func (*SmtpConnection) RespondWithError

func (self *SmtpConnection) RespondWithError(code int, explanation string)

Send an error message back to the client with the given SMTP error code and explanation text. This will NOT terminate the connection for you; if you want that, you'll have to do it yourself.

func (*SmtpConnection) RespondWithRCode

func (self *SmtpConnection) RespondWithRCode(code *SmtpReturnCode)

Send the given SMTP return code back to the client. This will NOT terminate the connection for you; if you want that, you'll have to do it yourself.

func (*SmtpConnection) SetUserdata

func (self *SmtpConnection) SetUserdata(data interface{})

Set up userdata for the connection, which can be used to make SmtpReceivers a bit more stateful.

type SmtpReceiver

type SmtpReceiver interface {
	// Invoked when a new connection is opened.
	ConnectionOpened(conn *SmtpConnection, peer net.Addr) SmtpReturnCode

	// Invoked when the connection has been closed.
	ConnectionClosed(conn *SmtpConnection)

	// Invoked when a HELO is received from the server.
	Helo(conn *SmtpConnection, hostname string, esmtp bool) SmtpReturnCode

	// Invoked when a MAIL From command is received.
	MailFrom(conn *SmtpConnection, sender string) SmtpReturnCode

	// Invoked when a RCPT To command is received.
	RcptTo(conn *SmtpConnection, recipient string) SmtpReturnCode

	// Invoked when a DATA command is received. Should invoke
	// GetDotReader on the connection if it is considered appropriate.
	Data(conn *SmtpConnection) SmtpReturnCode

	// Invoked when an ETRN command was received.
	Etrn(conn *SmtpConnection, domain string) SmtpReturnCode

	// Invoked when an RSET command was received.
	Reset(conn *SmtpConnection) SmtpReturnCode

	// Invoked when a QUIT command was received.
	Quit(conn *SmtpConnection) SmtpReturnCode
}

Callback implementation for SMTP servers.

type SmtpReturnCode

type SmtpReturnCode struct {
	// SMTP error/success code to return to the client.
	Code int

	// Text representation of the message the client should get.
	Message string

	// Whether or not to terminate the connection after the command.
	Terminate bool
}

Generic SMTP return code; indicates what the server should respond to the client.

Directories

Path Synopsis
Main caller of the SMTP server.
Main caller of the SMTP server.

Jump to

Keyboard shortcuts

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