Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mail.SMTPTransport

THE SMTP HALF OF StreamSec.Mail.Transport. Everything that moves octets,
  performs the handshake, bounds a peer and reaps a thread is in that unit and
  is spoken by POP3 and IMAP too; what is here is the part that is SMTP and
  could not honestly be anything else:

    - the ports, 25 and 587, and 465 for the implicit-TLS attachment;
    - RFC 5321's five-minute floor for silence between commands, which is not
      RFC 1939's ten or RFC 3501's thirty;
    - the admission caps an MX was sized for - transient transactions that
      drain in seconds, not the all-day sessions a mailbox server holds;
    - tSmtpPortRole, the inbound-exchanger against submission distinction that
      decides whether a port may relay at all. POP3 and IMAP have no such
      question: every octet they serve is already in a mailbox on this host.

  AND THE FOUR PER-PROTOCOL CLASSES. A listener IS its port, so the listener,
  the channel it mints, the thread that drives the conversation and the
  configuration that describes it all descend from their neutral bases here.
  tSmtpChannel and tSmtpConnectionThread are nearly empty today; that is the
  honest state of them, and they exist now rather than later because adding a
  class between a shipped base and its consumers is a compatibility event and
  declaring one is not.

  THE INTERFACES DESCEND, AND THEY KEEP THE ORIGINAL GUIDs. iSmtpChannel,
  iSmtpConnectionHandler and iSmtpConnectionFactory are the same contracts they
  have always been, so the identifiers stay with them and the neutral bases got
  fresh ones. That direction matters: Delphi's QueryInterface does not walk
  interface ancestry, so if a base carried the SMTP GUID then Supports(aPop3
  Channel,iSmtpChannel) would succeed and the split would guard nothing.

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

Classes, interfaces and records

classeSmtpTransportError

inherits from eMailTransportError

Still raised by everything in this unit, and now also caught by anything that handles the neutral base - which is what lets a consumer serving three protocols write one handler.

(no public members)

classtSmtpListenerOptions

(no public members)

interfaceiSmtpChannel

inherits from iMailChannel

WHAT AN SMTP CONVERSATION SEES OF ITS TRANSPORT. No members of its own: the contract is the base's, and this exists so that the type an SMTP handler is handed says SMTP - and so that a POP3 channel cannot satisfy it.

(no public members)

interfaceiSmtpConnectionHandler

inherits from iMailConnectionHandler

ONE SMTP CONNECTION'S CONVERSATION, from the driver's side.

(no public members)

interfaceiSmtpConnectionFactory

inherits from iMailConnectionFactory

Mints a handler per accepted SMTP connection. The relay component implements it. IT IS HANDED THE OPTIONS OBJECT, NOT A ROLE - the configuration of the port the connection arrived on, already typed, so the factory reads Role off the object itself and needs no second lookup that could pick the other port's configuration. Both parameters are typed for the same reason the base declares no method at all: a neutral signature would put an interface cast and an UNCHECKED class cast on the accept path, and one of those failures is an open relay.

function NewHandler(const aChannel: iSmtpChannel; aOptions: tSmtpListenerOptions): iSmtpConnectionHandler;

classtSmtpChannel

inherits from tMailChannel

implements iSmtpChannel

ONE SMTP CONNECTION'S OCTETS. Empty today, and that is the honest statement of it: the class exists because the channel is per-protocol, and because the one line that names a concrete channel class - tMailListener.NewChannel - has to have something to name. A POP3 channel will not be empty: RETR pushes whole messages through the blocked-write path, where SMTP only ever pushes short replies.

(no public members)

classtSmtpListenerOptions

inherits from tMailListenerOptions

WHAT AN SMTP PORT IS, on top of what a bound socket is.

constructor Create(aOwner: TPersistent); overload; override;
THE ROLE-FREE BASE CONSTRUCTOR IS NOT A LEGAL WAY TO BUILD ONE OF THESE, and it raises rather than defaulting. Full description »
constructor Create(aOwner: TPersistent; aRole: tSmtpPortRole); reintroduce; overload; property Role: tSmtpPortRole read fRole;
Fixed by whoever created it: an inbound port cannot be turned into a submission port by editing a property, because the two differ in what they will relay. AssignTo does not copy it either, so it is immutable for the object's whole life - which is what makes it safe as the sole discriminator on the relay gate.
property MaxConnections default cSmtpDefaultMaxConnections;
REDECLARED ONLY TO CARRY A DIFFERENT `default`. A property override needs no type and no read/write - it inherits both - and it touches nothing private in the base's unit, which is what makes it legal from here. The base deliberately declares none of the four, because `default` is only ever correct beside the constructor that produces the value, and that constructor is this one.
property MaxConnectionsPerPeer default cSmtpDefaultMaxPerPeer; property IdleTimeoutSeconds default cSmtpDefaultIdleSeconds; property SessionTimeoutSeconds default cSmtpDefaultSessionSeconds; property PreambleIdleSeconds default cSmtpDefaultPreambleIdleSeconds; property PreambleSessionSeconds default cSmtpDefaultPreambleSessionSeconds; property PreamblePressurePercent default cSmtpDefaultPreamblePressurePercent;

classtSmtpListener

(no public members)

classtSmtpConnectionThread

inherits from tMailConnectionThread

The SMTP driver. It overrides exactly two things: who answers a connection, and what this protocol calls the upgrade in a log line.

(no public members)

classtSmtpListener

inherits from tMailListener

ONE BOUND SMTP PORT. Not an empty descendant even today: it names the two per-protocol classes, and it re-exposes its configuration and its factory in the types the SMTP driver needs. Both are necessary rather than decorative - the base declares Options and Factory protected, and protected on ANOTHER class in another unit is unreachable from tSmtpConnectionThread, which is not a descendant of the listener.

constructor Create(aOptions: tSmtpListenerOptions; const aFactory: iSmtpConnectionFactory; aEngine: TsmSimpleTLSInternalServer); reintroduce; property Options: tSmtpListenerOptions read fSmtpOptions;
Typed views of what the base holds. Kept as fields set from the constructor's own parameters rather than as casts, so there is no place where a wrong options class could be read as this one - and tSmtpListenerOptions(aPop3Options) would be a LEGAL unchecked cast whose first descendant field is Ro... Full description »
property Factory: iSmtpConnectionFactory read fSmtpFactory;

Types (enumerations, sets, aliases)

enumtSmtpPortRole

WHICH SECURITY POSTURE AN SMTP PORT HAS, not decoration. It decides whether the listener may relay at all and whether it offers AUTH - see StreamSec.Mail.SMTPServer, which reads it off the options object it is handed with every accepted connection. IT HAS EXACTLY TWO MEMBERS AND MUST NEVER GROW A THIRD for a protocol that is not SMTP. RelayPermittedOn(sprInbound) = False and an inbound AuthMechanisms of [] are two independent barriers against an open relay, and both are written as tests on this enum.

  tSmtpPortRole = (
    { An inbound mail exchanger, conventionally port 25. Accepts mail for the
      domains this host serves, FROM ANYBODY, and relays nothing. }
    sprInbound,
    { Message submission (RFC 6409), conventionally port 587. Relays for
      authenticated senders, and takes nothing from a session that has not
      authenticated (RFC 6409 sec.4.3) - see TsmCustomSMTPServer.Submission. }
    sprSubmission);

Routines