Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mail.IMAPTransport

THE IMAP HALF OF StreamSec.Mail.Transport, and the exact counterpart of
  StreamSec.Mail.POP3Transport. Everything that moves octets, performs the
  handshake, bounds a peer and reaps a thread is in that unit; what is here is
  what is IMAP and could not honestly be anything else:

    - the ports, 143 and 993;
    - RFC 3501 sec.5.4's THIRTY-minute floor for the autologout timer, which is
      not RFC 1939's ten and not RFC 5321's five;
    - admission caps sized for a client that legitimately opens SEVERAL
      connections at once, which POP3's are not;
    - the four per-protocol classes, because a listener IS its port.

  IDLE IS WHY THE TIMERS ARE WHAT THEY ARE. A client in IDLE sends nothing for
  as long as the server lets it, and RFC 2177 tells it to re-issue at least
  every 29 minutes. An idle bound below that would drop a perfectly healthy
  connection at a moment when the client is doing exactly what it was told, so
  1800 seconds is a FLOOR here rather than a default anybody should lower.
  The session bound is a day, not the half hour POP3 uses: a POP3 session holds
  an exclusive maildrop lock and a long one is a denial of service against the
  account's owner, while an IMAP session holds nothing anybody else needs.

  THE INTERFACES DESCEND AND CARRY THEIR OWN GUIDs, so an IMAP channel does not
  satisfy iPop3Channel and vice versa. Delphi's QueryInterface does not walk
  interface ancestry, which is what makes that separation real rather than
  decorative.

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

Classes, interfaces and records

classeImapTransportError

inherits from eMailTransportError

(no public members)

classtImapListenerOptions

(no public members)

interfaceiImapChannel

inherits from iMailChannel

What an IMAP conversation sees of its transport. No members of its own - the contract is the base's; this exists so the type an IMAP handler is given says IMAP, and so a POP3 channel cannot satisfy it.

(no public members)

interfaceiImapConnectionHandler

inherits from iMailConnectionHandler

(no public members)

interfaceiImapIdleHandler

WHAT IDLE NEEDS OF THE DRIVER: a call on the connection's own thread while the peer is silent, which is the only moment new mail can be pushed to a client that is waiting for it (RFC 2177). A SEPARATE INTERFACE rather than a member of iImapConnectionHandler, so that interface - and every handler already written against it - stays as it is; the driver asks for this one and does nothing when a handler does not offer it.

procedure IdleRound;
Called about once a second while no octet arrives. Must return promptly: it runs on the thread that reads the connection.

interfaceiImapConnectionFactory

inherits from iMailConnectionFactory

Mints a handler per accepted IMAP connection; the server component implements it. Both parameters typed for the same reason the POP3 factory types its own - a neutral signature would put an interface cast and an unchecked class cast on the accept path.

function NewHandler(const aChannel: iImapChannel; aOptions: tImapListenerOptions): iImapConnectionHandler;

classtImapChannel

inherits from tMailChannel

implements iImapChannel

ONE IMAP CONNECTION'S OCTETS. Like the POP3 channel it adds nothing yet, and for the same reason it will not stay that way: FETCH BODY[] pushes whole messages through the blocked-write path, and an APPEND pulls one the other way, so this is where a cumulative bound belongs when one is added.

(no public members)

classtImapListenerOptions

inherits from tMailListenerOptions

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

constructor Create(aOwner: TPersistent); override; property MaxConnections default cImapTransportMaxConnections;
REDECLARED ONLY TO CARRY THIS PROTOCOL'S defaults - the base deliberately declares none, because `default` is only correct beside the constructor that produces the value, and that constructor is this one.
property MaxConnectionsPerPeer default cImapTransportMaxPerPeer; property IdleTimeoutSeconds default cImapTransportIdleSeconds; property SessionTimeoutSeconds default cImapTransportSessionSeconds; property PreambleIdleSeconds default cImapTransportPreambleIdleSeconds; property PreambleSessionSeconds default cImapTransportPreambleSessionSeconds; property PreamblePressurePercent default cImapTransportPreamblePressurePercent;

classtImapListener

(no public members)

classtImapConnectionThread

inherits from tMailConnectionThread

The IMAP driver. It overrides three things: who answers a connection, what this protocol calls the upgrade in a log line - IMAP spells it STARTTLS, which POP3 does not, and a log that says STLS sends somebody to the wrong RFC - and the idle round, which IDLE is the reason the base has at all.

(no public members)

classtImapListener

inherits from tMailListener

ONE BOUND IMAP PORT.

constructor Create(aOptions: tImapListenerOptions; const aFactory: iImapConnectionFactory; aEngine: TsmSimpleTLSInternalServer); reintroduce; property Options: tImapListenerOptions read fImapOptions;
Typed views of what the base holds protected. Both are needed rather than decorative: protected on another class in another unit is unreachable from tImapConnectionThread, which is not a descendant of the listener. Kept as fields set from the constructor's own parameters, so no cast can be wrong.
property Factory: iImapConnectionFactory read fImapFactory;