smtp

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend implements the smtp.Backend interface required by go-smtp

func (*Backend) NewSession

func (b *Backend) NewSession(_ *smtp.Conn) (smtp.Session, error)

NewSession creates a new SMTP session for each client connection

type Email

type Email struct {
	// Unique identifier for the email
	ID string `json:"id"`
	// Sender's email address
	From string `json:"from"`
	// List of recipient email addresses
	To []string `json:"to"`
	// Carbon copy recipients
	Cc []string `json:"cc"`
	// Blind carbon copy recipients
	Bcc []string `json:"bcc"`
	// Reply-to email address
	ReplyTo string `json:"replyTo"`
	// Email subject line
	Subject string `json:"subject"`
	// Plain text content of the email
	Body string `json:"body"`
	// HTML content of the email, if available
	HTML string `json:"html"`
	// Time when the email was received
	Timestamp time.Time `json:"timestamp"`
	// Raw email content in its original form
	Raw string `json:"raw"`
	// Additional headers
	Headers map[string][]string `json:"headers"`
}

Email represents a received email message with all its components

type Server

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

Server represents our SMTP server implementation It handles email reception and storage in memory

func NewServer

func NewServer(host string, port int, auth, username, password, tlsMode string) *Server

NewServer creates and configures a new SMTP server instance Parameters:

  • host: The hostname or IP to listen on
  • port: The port number to listen on
  • auth: Authentication mode
  • username: Authentication username
  • password: Authentication password
  • tlsMode: TLS configuration mode

func (*Server) EmailsChan

func (s *Server) EmailsChan() <-chan *Email

EmailsChan returns the channel used for real-time email notifications Consumers can listen on this channel to receive new emails as they arrive

func (*Server) GetEmails

func (s *Server) GetEmails() []*Email

GetEmails returns a copy of all stored emails in a thread-safe manner

func (*Server) Start

func (s *Server) Start() error

Start begins listening for SMTP connections in a separate goroutine

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully shuts down the SMTP server

type Session

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

Session represents an active SMTP session with a client

func (*Session) Data

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

Data handles the DATA command in the SMTP protocol It receives the email content and processes it

func (*Session) Logout

func (s *Session) Logout() error

Logout handles client disconnection

func (*Session) Mail

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

Mail handles the MAIL FROM command in the SMTP protocol

func (*Session) Rcpt

func (s *Session) Rcpt(to string, opts *smtp.RcptOptions) error

Rcpt handles the RCPT TO command in the SMTP protocol

func (*Session) Reset

func (s *Session) Reset()

Reset clears the current session state

Jump to

Keyboard shortcuts

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