package smtp

import (
	"io"
	"log"
)

type Handler interface {
	ServeSMTP(from string, to []string, r io.Reader) error
}

type Session struct {
	ID      string
	Handler Handler
}

func (s *Session) Send(from string, to []string, r io.Reader) error {
	log.Printf("session=%d from=%s to=%s", s.ID, from, to)

	// TODO: a chain of middlewares here
	return s.Handler.ServeSMTP(from, to, r)
}

func (s *Session) Logout() error {
	log.Printf("Ending session %d", s.ID)

	return nil
}
