Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mail.Retrieval

EVERYTHING A MAILBOX-ACCESS SERVER NEEDS THAT IS NOT ITS PROTOCOL.
  TsmCustomMailRetrievalServer is the base the per-protocol components descend
  from - StreamSec.Mail.POP3Server today, an IMAP one to follow. Only the engine
  and the per-connection session differ between those; the store, the accounts,
  the TLS engine, the authentication gate, the counters and the listener
  start/stop contract are the same, so they are here and there is exactly one of
  each. StartListeners and StopListeners are abstract BECAUSE THE LISTENER
  CLASSES ARE PER PROTOCOL - a listener is its port, and 110 and 143 are not the
  same port.

  IT CARRIES NOTHING ONWARD FOR ANYBODY. Every octet a retrieval server emits is
  already in a mailbox on this host, and the only identity it recognises is the
  account whose mailbox that is. There is no relay gate here because there is
  nothing to relay - which is why tSmtpPortRole has no third member and why a
  retrieval port needs none of the SMTP server's machinery.

  THE THREE THINGS IT WIRES TOGETHER, and the one rule each brings:

    Store   StreamSec.Mail.Maildir. THE SAME OBJECT the inbound SMTP server
            delivers into - not a second one pointed at the same directory,
            because the lock that guards an index rewrite only guards it
            against holders of the same lock.
    Users   StreamSec.Mail.Users. The Argon2id account store. WITHOUT IT, AND
            WITHOUT AN OnAuthenticate HANDLER, NOTHING AUTHENTICATES - the
            deny-by-default the whole family keeps.
    TLS     StreamSec.Mobile.TlsInternalServer, for the in-band upgrade. The
            implicit-TLS port is a TsmAsyncTLSServer and belongs to the
            descendant, because the plugin it registers is per protocol.

  THE AUTHENTICATION GATE COLLAPSES EVERY FAILURE into one verdict on purpose:
  the account store's distinctions go to the log and no further, or a sign-in
  command becomes an account enumerator.

Feature notes: Mail subsystem notes (SMTP / POP3 / IMAP)

Classes, interfaces and records

classeMailRetrievalError

inherits from Exception

(no public members)

classTsmCustomMailRetrievalServer

(no public members)

classTsmCustomMailRetrievalServer

inherits from TComponent

EVERYTHING POP3 AND IMAP SHARE. Only the engine and the per-connection session differ between them, so everything else is here.

constructor Create(AOwner: TComponent); override; destructor Destroy; override; property SessionsServed: Integer read fSessionsServed;
Connections served since this component was created. A lifetime total, not a live count.
property Store: TsmMailStore read fStore write SetStore;
THE MAILBOX TREE. The same TsmMailStore the inbound SMTP server delivers into - see the unit header for why it must be the same object. Nothing is served without it.
property Users: TsmMailUsers read fUsers write SetUsers;
THE PASSWORD ACCOUNTS. Leaving it nil means only OnAuthenticate can admit anybody, and with neither, nothing authenticates.
property TLSServer: TsmSimpleTLSInternalServer read fTLSServer write SetTLSServer;
THE ENGINE THAT ANSWERS AN STLS on the cleartext port: its certificate is what the upgrade presents. A listener whose TLSMode is not mtmDisabled refuses to start without it, rather than advertising an upgrade it cannot perform.
property ServerName: string read fServerName write fServerName;
This host's name, for the greeting.
property Banner: string read fBanner write fBanner;
Replaces the greeting text. Leave it '' for the default. IT IS NOT A SECURITY MEASURE, and it must not end with '<...>': that is how a client detects APOP, which this server cannot answer.
property Active: Boolean read fActive write SetActive default False; property OnAuthenticate: tMailAuthenticateEvent read fOnAuthenticate write fOnAuthenticate; property OnSessionOpened: tMailSessionEvent read fOnSessionOpened write fOnSessionOpened; property OnSessionClosed: tMailSessionEvent read fOnSessionClosed write fOnSessionClosed; property OnLog: tMailServerLogEvent read fOnLog write fOnLog;

Types (enumerations, sets, aliases)

proctMailAuthenticateEvent

The credential, in wiped storage - never a plain string, and never reached over a cleartext channel (the engine refuses the mechanism outright there). aAllow arrives holding the account store's verdict, so a handler that changes nothing keeps it, and one that sets it False can veto a peer the store would have admitted.

  tMailAuthenticateEvent = procedure (Sender: TObject; const aUser: string;
                                      const aPassword: iSecretKey;
                                      var aAllow: Boolean) of object;

proctMailSessionEvent

A session has opened or closed a maildrop. For a status display and for the log; raised from connection threads, so a handler must be thread-safe.

  tMailSessionEvent = procedure (Sender: TObject; const aUser: string;
                                 aMessages: Integer) of object;

proctMailServerLogEvent

  tMailServerLogEvent = procedure (Sender: TObject; const aText: string;
                                   aFatal: Boolean) of object;