API Reference
StreamSec.Mail.SMTPServer
SMTP server: MX, submission and local delivery - StreamSec.Mail.SMTPServer
Binds the SMTP receive engine (StreamSec.Mail.SMTPEngine) and the on-disk queue
(StreamSec.Mail.SMTPSpool) to TsmAsyncTLSServer, as one component to drop on a
form beside the server:
mta := TsmSMTPServer.Create(Self);
mta.ServerName := 'mail.example.com';
mta.LocalDomains.Add('example.com'); // inbound mail we accept
mta.SpoolDirectory := 'C:\mailspool';
mta.SmarthostHost := 'smtp.provider.net'; // where the rest goes
mta.OnAuthenticate := CheckPassword; // who may relay
mta.Server := tls; // the TsmAsyncTLSServer
mta.Active := True;
tls.BindPort := 465;
tls.FallbackPolicy := fbpUseFallback; // SEE BELOW - required
tls.Active := True;
THREE WAYS IN, AND THEY COEXIST ON ONE INSTANCE.
Server a TsmAsyncTLSServer -> IMPLICIT TLS (SMTPS, RFC 8314), on
whatever port that server binds,
conventionally 465
Inbound this component's own -> cleartext + in-band STARTTLS (RFC 3207),
listener conventionally 25, the MX role
Submission this component's own -> cleartext + in-band STARTTLS (RFC 6409),
listener conventionally 587
All three may be Active together. The async path is implicit TLS because every
accepted socket is a TLS record stream from the first octet (AsyncTLSServer.txt
section 3), so there is no plaintext phase in which a STARTTLS could be issued;
the two own listeners are the opposite, and what they will accept is set by
TLSMode (mtmDisabled / mtmOpportunistic / mtmRequired). ONE implementation of
iSmtpServerPolicy serves all of them, which is what stops the relay gate from
differing between ports.
THE ONE COMBINATION THAT IS NOT OFFERED: an own listener cannot do implicit
TLS. tMailTlsMode describes the in-band upgrade and nothing else, so implicit
TLS comes from a TsmAsyncTLSServer or not at all - and one of those binds one
port, so a second implicit-TLS port means a second TsmAsyncTLSServer.
ALPN CANNOT SELECT THE Server PATH, WHICH IS WHY IsFallback EXISTS. There is no registered
ALPN identifier for SMTP - IANA's registry has imap, pop3 and managesieve but
nothing for submission - and real SMTPS clients offer no ALPN at all. So a
connection arriving here has negotiated NOTHING, and the server resolves it
through tFallbackPolicy, which defaults to fbpRefuse. Two settings are needed
and setting only one leaves the port apparently dead:
tls.FallbackPolicy := fbpUseFallback; and mta.IsFallback := True;
or fbpFirstRegistered if this is the only protocol on that server. AlpnToken is
still published, and is advertised, so a client that DOES offer 'smtp' is
routed by it - but nothing should be built on that happening.
IN PRACTICE, GIVE IT ITS OWN SERVER INSTANCE. Sharing a port with HTTPS means
one of the two must win every un-negotiated connection, and mail and web both
arrive without ALPN. One TsmAsyncTLSServer on 443 for the web, another on 465
for this.
DENY BY DEFAULT. The relay gate is closed until something opens it: a recipient
is accepted when it is in a LOCAL DOMAIN (inbound mail this host serves), or
when the session authenticated, or when the peer presented a client certificate
and RelayForClientCertificate is set, or when the peer is in RelayNetworks.
OnCheckRelay then gets the last word on every recipient. With none of those
configured the server accepts nothing and relays nothing, which is the right
thing for a component that has not been told its policy yet.
AN AUTHENTICATED ACCOUNT SENDS AS ITSELF. After SMTP AUTH, MAIL FROM takes the
account's own address, the null path, an address the connection's client
certificate asserts, or one OnCheckSenderIdentity allows; anything else is
refused with 550 5.7.1 (RFC 6409 sec.6.1).
Feature notes: Mail subsystem notes (SMTP / POP3 / IMAP)
Classes, interfaces and records
classTsmCustomSMTPServer
(no public members)
classTsmCustomSMTPServer
BOTH FACTORY INTERFACES ARE LISTED. Only iSmtpConnectionFactory is used - it is what tSmtpListener takes and what declares NewHandler - but Delphi's QueryInterface does not walk interface ancestry, so a class listing only the descendant does not answer to the base. Co-listing costs one identifier and is what makes Supports(aServer,iMailConnectionFactory) true for anything written later against the neutral transport.
function DkimDnsName: string;
The owner name the public key must be published at, and the TXT record to publish there, both built from the CURRENT DkimKey / DkimSelector / DkimDomain / DkimAlgorithm.
Full description »
function DkimDnsRecord: string;
property Authenticator: tSmtpMessageAuthenticator read GetAuthenticator;
The inbound gate, created on first use. Every policy switch lives here - RejectBrokenSignature, EnforceDmarc, RequirePublishedPolicy and the rest - so they are configured on this rather than duplicated as published properties of the component.
» member page
property SpamFilter: tSpamFilter read fSpamFilter write fSpamFilter;
THE SPAM PIPELINE, or nil for a server that does not filter. A REFERENCE, NOT AN OWNED OBJECT, and deliberately not a published property: everything about it - which checks, what each is worth, where the thresholds sit - is deployment policy that no component could sensibly default, and several s...
Full description »
property Resolver: iDnsResolver read GetResolver write fResolver;
Substitute a resolver - a scripted one for tests, or a DNSSEC-validating stub. Assigning nil restores the built-in DNS-over-TCP resolver.
» member page
property OnMailAuth: tSmtpAuthReportEvent read fOnMailAuth write fOnMailAuth;
The last word on an inbound message. Fires after every check, with the whole report and the recommended disposition.
» member page
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function AppProtocol: iAppProtocol;
Register this with TsmAsyncTLSServer.Protocols.AddProtocol when the plugin is wired up from code rather than by assigning Server.
Full description »
procedure Start;
Starts the delivery queue: recovers whatever a previous run left on disk and begins attempting it. ACCEPTING MAIL DOES NOT REQUIRE THIS - a message is spooled durably whether the queue is running or not, which is what makes an accept honest - but nothing leaves the queue until it is.
» member page
procedure Stop;
procedure QueueSnapshot(aDest: TList);
Whatever is queued now, for a status display. Reads the live items and lets go, so treat what it returns as a snapshot rather than a handle.
» member page
property QueueLength: Integer read GetQueueLength;
property SessionsServed: Integer read fSessionsServed;
Connections this server has served since it was created. A lifetime total, not a live count.
» member page
property SmarthostPassword: iSecretKey read GetSmarthostPasswordRef write SetSmarthostPasswordRef;
The wiped-storage credential for the smarthost. Assign it directly, or use the component's SetSmarthostPassword.
» member page
procedure SetSmarthostPassword(const aValue: string);
property OnConfigureDelivery: tSmtpAgentConfigureEvent read GetOnConfigureDelivery write SetOnConfigureDelivery;
Where the outbound leg's trust anchors and client identity are loaded - it is handed the TsmSMTPClient for each delivery, before Open. WITHOUT A HANDLER the client trusts nothing and every delivery fails closed, which is the correct direction for a component that has not been told whom to trust.
» member page
property DeliveryAgent: iSmtpDeliveryAgent read fDeliveryAgent write SetDeliveryAgent;
REPLACES THE BUILT-IN SMARTHOST AGENT on the queue. An MX with no smarthost installs a tSmtpLocalAgent or a tSmtpRouterAgent here, which is also what lets a bounce addressed to a local postmaster be delivered at all. Set it before Active.
» member page
property MailboxStore: iSmtpMailboxStore read fStore;
The mailbox store in use, once Active - the built-in maildir under MailboxRoot, or nil in sldNone/sldEvent.
» member page
property TLSServer: TsmSimpleTLSInternalServer read fTLSServer write SetTLSServer;
THE ENGINE THAT ANSWERS A STARTTLS on the cleartext ports: its certificate is what the upgrade presents.
Full description »
property Inbound: tSmtpListenerOptions read fInbound write SetInbound;
THE INBOUND MAIL EXCHANGER, conventionally port 25. Disabled by default. It accepts mail for LocalDomains and configured Mailboxes FROM ANYBODY, and relays nothing unless AllowRelayOnInbound says otherwise.
Full description »
property Submission: tSmtpListenerOptions read fSubmission write SetSubmission;
MESSAGE SUBMISSION over cleartext-then-STARTTLS, conventionally port 587, for clients that cannot do implicit TLS on 465.
Full description »
property Store: TsmMailStore read fSharedStore write SetSharedStore;
Where the built-in maildir lives, one subdirectory per mailbox. THE SAME MAILDIR THE RETRIEVAL SERVERS READ, and the only correct way to run SMTP beside POP3 or IMAP.
Full description »
property MailboxRoot: string read fMailboxRoot write fMailboxRoot;
property Mailboxes: TStringList read fMailboxes write SetMailboxes;
'alice@example.com=alice' - the address this host accepts, and the directory its mail goes in. The address is matched case-insensitively; the directory must be a plain, safe name (no separators), which is checked.
» member page
property LocalDeliveryMode: tSmtpLocalDeliveryMode read fLocalDeliveryMode write SetLocalDeliveryMode default sldNone;
property RequireKnownMailbox: Boolean read fRequireKnownMailbox write fRequireKnownMailbox default True;
Refuse a recipient in one of our own domains when no mailbox resolves for it, with 550 'no such user here'.
Full description »
property AllowRelayOnInbound: Boolean read fAllowRelayOnInbound write fAllowRelayOnInbound default False;
Let the INBOUND port relay - i.e. carry mail that is not for one of our domains - for a peer that authenticated, presented a certificate or sits in RelayNetworks. OFF BY DEFAULT AND IT SHOULD STAY OFF: port 25 is where the whole internet can reach you, and every open-relay incident is this switch in the wrong position. Use the submission port for senders that relay.
» member page
property PostmasterMailbox: string read fPostmasterMailbox write fPostmasterMailbox;
The mailbox <postmaster@ourdomain> and <Postmaster> are delivered to. RFC 5321 sec.4.5.1 requires the address to work on any host that receives mail, so it is resolved BEFORE the store and cannot be made unreachable by an unknown-user policy.
Full description »
property ForgedSubjectPrefix: string read fForgedSubjectPrefix write fForgedSubjectPrefix;
WHAT THE SUBJECT OF A FORGERY SAYS: a message that came with a field naming this host that it did not write - an Authentication-Results, X-DNS-Warning or X-Stripped-Fields, kept renamed X-Forged- (StreamSec.Mail.MessageAuth) - is not delivered looking clean.
Full description »
property JunkFolder: string read fJunkFolder write fJunkFolder;
WHERE A LOCAL MAILBOX'S COPY OF A FORGERY GOES - a message that came with a field in this host's name it did not write, kept renamed X-Forged-, whether or not a SpamFilter is assigned: this folder of the mailbox, WHEN THE MAILBOX HAS ONE.
Full description »
property OnResolveMailbox: tSmtpResolveMailboxEvent read fOnResolveMailbox write fOnResolveMailbox;
property OnLocalDeliver: tSmtpLocalDeliverEvent read fOnLocalDeliver write fOnLocalDeliver;
property Server: TsmAsyncTLSServer read fServer write SetServer;
The async TLS server this plugin is served by. Assigning it registers this plugin with that server's protocol registry (clearing it unregisters), so the association is declared in the Object Inspector instead of from code. The registration is keyed by the plugin INSTANCE, not by its token.
» member page
property Users: TsmMailUsers read fUsers write SetUsers;
THE PASSWORD ACCOUNTS, one per mailbox. Assigning it enables SMTP AUTH; leaving it nil means only OnAuthenticate can admit anybody, and with neither, nothing authenticates. The store is consulted BEFORE OnAuthenticate, which then sees its verdict and may narrow it.
» member page
property IsFallback: Boolean read fIsFallback write fIsFallback default False;
THE PROTOCOL THAT ANSWERS A CONNECTION WHICH NEGOTIATED NOTHING - which for SMTPS is every connection, because no SMTP client offers ALPN. Setting it is half of what this plugin needs; the server's own FallbackPolicy must be fbpUseFallback (or fbpFirstRegistered) or the fallback is never consulted and the port appears dead. See the unit header.
» member page
property AlpnToken: string read fAlpnToken write SetAlpnToken;
The ALPN identifier advertised for SMTP. Private-use: IANA has registered none. Settable only until the application protocol has been handed to a registry, exactly as TsnipTLSServer.AlpnToken is - after that the token IS a live registry key read on reactor threads.
» member page
property AlpnPriority: Integer read fAlpnPriority write SetAlpnPriority default cAlpnPriorityDefault;
Where this protocol sits in the server's ALPN preference list; higher is preferred. Rarely relevant here, since selection is by fallback. Not settable while the server is active.
» member page
property Active: Boolean read fActive write SetActive default False;
Starts and stops the DELIVERY QUEUE. It is not the listening socket - that is the server's Active - and a relay whose queue is stopped still accepts mail durably; it simply does not send any.
» member page
property ServerName: string read fServerName write SetServerName;
This host's name: the 220 banner, the EHLO response and the Received stamp. Set it to the public FQDN.
» member page
property Banner: string read fBanner write fBanner;
Replaces the greeting text after the 220. Leave it '' for the default. IT IS NOT A SECURITY MEASURE: hiding the software name here does not stop anyone fingerprinting the server, and a banner that lies about what it is breaks interoperability workarounds in real clients.
» member page
property LocalDomains: TStringList read fLocalDomains write SetLocalDomains;
Domains this host accepts INBOUND mail for. A recipient in one of these is accepted from anybody - that is what being a mail exchanger means - so a domain here is a domain whose mail this server undertakes to deliver. Matching is case-insensitive on the part after the '@', exact: putting 'example.com' here does NOT accept 'mail.example.com'.
» member page
property RelayNetworks: TStringList read fRelayNetworks write SetRelayNetworks;
Peer addresses permitted to RELAY without authenticating, as IPv4 addresses or CIDR ranges ('10.0.0.0/8', '192.0.2.7'). Empty by default, which is the safe answer: an address-based rule authorizes whoever holds the address. Prefer authentication, and keep this for a fronting proxy or an internal segment you control.
» member page
property RelayForClientCertificate: Boolean read fRelayForClientCertificate write fRelayForClientCertificate default False;
Let a peer that presented a verified client certificate relay. The handshake has already checked the certificate against the server's trust configuration, so this is an authorization switch, not an authentication one - and it authorizes EVERY client the server's trust configuration admits. Narrow it with OnClientCertificate.
» member page
property RequireAuth: Boolean read fRequireAuth write fRequireAuth default False;
Refuse MAIL FROM until the session has authenticated with SMTP AUTH, on EVERY port. The submission port refuses an unauthenticated session on its own (see Submission); this extends the refusal to the server as a whole.
Full description »
property AuthMechanisms: tSmtpServerAuths read fAuthMechanisms write fAuthMechanisms;
Which SASL mechanisms are offered. Both by default - and neither is offered or accepted on a cleartext channel, which under this server cannot arise anyway.
» member page
property BareNewlinePolicy: tSmtpBareNewlinePolicy read fBareNewlinePolicy write fBareNewlinePolicy default sbnReject;
What to do about a bare CR or LF inside message data. Rejecting is the default and is what closes the SMTP-smuggling class of attack against the NEXT hop; normalizing accepts mail from sloppy clients at the cost of rewriting their octets. See tSmtpBareNewlinePolicy.
» member page
property OfferSmtpUtf8: Boolean read fOfferSmtpUtf8 write fOfferSmtpUtf8 default False;
Advertise SMTPUTF8 (RFC 6531). Off by default: accepting UTF-8 addresses commits every downstream hop to handling them.
» member page
property Limits: tSmtpLimits read fLimits write SetLimits;
The per-session bounds - message size, recipients, error budgets. See tSmtpLimits, where each one is documented with what it exists to stop.
» member page
property SpoolDirectory: string read fSpoolDirectory write SetSpoolDirectory;
Where undelivered mail lives. REQUIRED for onward relay: with this empty there is nowhere to put a message, so OnMessage arrives pre-loaded with smaRefuse and a handler that leaves it there answers 451.
» member page
property Postmaster: string read fPostmaster write SetPostmaster;
The address bounces come from. Empty means no bounces are generated at all and an undeliverable message is dropped after OnUndeliverable - which is quiet, and wrong for anything but a closed system.
» member page
property RetryIntervals: string read GetRetryIntervals write SetRetryIntervals;
Comma-separated retry intervals in seconds; the last one repeats.
» member page
property MaxAge: Integer read GetMaxAge write SetMaxAge;
Seconds a message may stay queued before it is bounced.
» member page
property SmarthostHost: string read GetSmarthostHost write SetSmarthostHost;
The smarthost every relayed message is handed to. This component does NOT resolve MX records: it is a submission relay, and the smarthost owns the rest of the journey.
» member page
property SmarthostSourceIP: string read GetSmarthostSourceIP write SetSmarthostSourceIP;
The built-in agent's local outbound source. Empty keeps OS selection. A custom DeliveryAgent owns its own corresponding setting.
» member page
property SmarthostPort: Word read GetSmarthostPort write SetSmarthostPort default 465;
465 for sdtImplicit, 587 for sdtRequired, 25 for sdtOpportunistic.
» member page
property SmarthostTLSMode: tSmtpDeliveryTlsMode read GetSmarthostTLSMode write SetSmarthostTLSMode default sdtImplicit;
HOW MUCH TLS THE ONWARD LEG INSISTS ON - see tSmtpDeliveryTlsMode. Defaults to sdtImplicit, which is the right answer for a smarthost you control. sdtOpportunistic exists for a destination you cannot dictate to and protects against a passive observer ONLY: an active attacker strips STARTTLS from the greeting and the message then goes in the clear.
» member page
property SmarthostTLSServer: TsmSimpleTLSInternalServer read GetSmarthostTLSServer write SetSmarthostTLSServer;
THE TRUST CONFIGURATION FOR THE ONWARD LEG, AND IT IS NOT TLSServer. TLSServer above is what a peer connecting to THIS host is answered with, and its RootCerts is simultaneously the set of anchors this server will accept a CLIENT CERTIFICATE under.
Full description »
property SmarthostUserName: string read GetSmarthostUserName write SetSmarthostUserName;
property OnAuthenticate: tSmtpAuthenticateEvent read fOnAuthenticate write fOnAuthenticate;
property OnCheckConnection: tSmtpCheckConnectionEvent read fOnCheckConnection write fOnCheckConnection;
THE FOUR CHECKS, in the order the conversation reaches them: the address, the name it claims, the reverse path, then each recipient. The first three arrive allowing; only the relay gate arrives refusing.
» member page
property OnCheckHelo: tSmtpCheckHeloEvent read fOnCheckHelo write fOnCheckHelo;
property OnCheckSender: tSmtpCheckSenderEvent read fOnCheckSender write fOnCheckSender;
property OnCheckSenderIdentity: tSmtpCheckSenderIdentityEvent read fOnCheckSenderIdentity write fOnCheckSenderIdentity;
Widens the submission sender rule for an account - see tSmtpCheckSenderIdentityEvent. It cannot narrow it; OnCheckSender, which runs after the rule, can.
» member page
property OnCheckRelay: tSmtpCheckRelayEvent read fOnCheckRelay write fOnCheckRelay;
property OnMessage: tSmtpMessageEvent read fOnMessage write fOnMessage;
property VerifyInbound: Boolean read fVerifyInbound write fVerifyInbound default False;
INBOUND: verify SPF, every DKIM signature, and DMARC, and refuse what the sending domain's own policy says to refuse. Off by default so an existing configuration does not start rejecting mail on upgrade - turning it on is a deliberate act.
» member page
property SignOutbound: Boolean read fSignOutbound write fSignOutbound default False;
OUTBOUND: sign everything the queue carries onward. Needs DkimDomain, DkimSelector and DkimKey; without them nothing is signed and mail still flows.
» member page
property DkimDomain: string read fDkimDomain write fDkimDomain;
The d= this server signs as - normally the domain it is authoritative for, NOT the domain in any particular message's From header.
» member page
property DkimSelector: string read fDkimSelector write fDkimSelector;
The s= selector, whose public key must be published at <selector>._domainkey.<DkimDomain> - see DkimDnsName and DkimDnsRecord, which build both from this and the key below.
» member page
property DkimKey: TComponent read fDkimKey write SetDkimKey;
THE SIGNING KEY, as a key COMPONENT - TstRSAKey for rsa-sha256 or TstEdDSAKey for ed25519-sha256. It is a plain TComponent reference so this unit stays free of any particular key class, exactly as TsmAcmeClient's AccountKey does; the design-time drop-down is narrowed to eligible private-key compo...
Full description »
property DkimAlgorithm: tDkimAlgorithm read fDkimAlgorithm write fDkimAlgorithm default dkaRsaSha256;
property OnClientCertificate: tSmtpClientCertEvent read fOnClientCertificate write fOnClientCertificate;
property OnLog: tSmtpServerLogEvent read fOnLog write fOnLog;
Queue and session events worth an operator's attention. Raised from reactor and delivery threads alike, so a handler must be thread-safe and must not block.
» member page
inherits from TsmCustomSMTPServer
(no public members)
Types (enumerations, sets, aliases)
enumtSmtpMessageAction
What is to become of a message whose DATA has completed. It arrives at OnMessage pre-loaded: smaSpool when a spool directory is configured, smaRefuse when none is - because a message with nowhere to go must not be accepted.
tSmtpMessageAction = (
{ Queue it for onward delivery and answer 250. The default. }
smaSpool,
{ The handler has taken responsibility for the message - written it to a
mailbox, handed it to an application queue - and the client is told 250.
Nothing is queued here. }
smaAccept,
{ Answer aCode / aText and do not queue. Use a 4xx code for "not now" and a
5xx for "never". }
smaRefuse);
enumtSmtpLocalDeliveryMode
WHERE MAIL FOR A LOCAL MAILBOX GOES.
tSmtpLocalDeliveryMode = (
{ No local delivery. A recipient in a local domain is accepted only when
RequireKnownMailbox is False, and OnMessage owns what happens to it. This
is what the component did before it could receive inbound mail. }
sldNone,
{ The component keeps a maildir under MailboxRoot, one directory per entry
in Mailboxes. }
sldMaildir,
{ The application resolves and stores: OnResolveMailbox says whether an
address is local, OnLocalDeliver writes it. Same contract as the built-in
store, including that a failure must RAISE. }
sldEvent);
proctSmtpResolveMailboxEvent
Does this host serve aRecipient itself? Set aLocal True and aMailbox to whatever OnLocalDeliver will understand. Runs at RCPT TO, so it must be quick: a sending MTA is waiting.
tSmtpResolveMailboxEvent = procedure (Sender: TObject;
const aRecipient: string;
var aMailbox: string;
var aLocal: Boolean) of object;
proctSmtpLocalDeliverEvent
Store one copy. RAISE to refuse - a normal return is the promise the 250 is built on, so a handler that is not sure the message is safe must throw.
tSmtpLocalDeliverEvent = procedure (Sender: TObject; const aMailbox: string;
const aRecipient: string;
const aEnvelope: iSmtpEnvelope;
const aData: tBytes) of object;
proctSmtpCheckRelayEvent
Called for each recipient of each transaction, and it is the last word on whether this server will carry that mail. aAllow arrives holding the built-in decision (local domain / authenticated / client certificate / peer network), so a handler that changes nothing keeps the configured policy - and a handler that sets it False can veto even an authenticated sender. aCode / aText are the refusal to send when aAllow ends up False.
tSmtpCheckRelayEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
const aRecipient: string;
var aAllow: Boolean;
var aCode: Integer;
var aText: string) of object;
proctSmtpCheckConnectionEvent
THE PEER'S ADDRESS, BEFORE THE BANNER. aEnvelope carries RemoteAddress, TransportInfo and SecureChannel and nothing else yet - nothing has been said. Refusing closes the connection. This is where a rate limit, a local blocklist or a reputation table belongs: it costs one reply.
tSmtpCheckConnectionEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
var aAllow: Boolean;
var aCode: Integer;
var aText: string) of object;
proctSmtpCheckHeloEvent
WHAT THE PEER CALLED ITSELF. A claim, not a fact: a forward lookup of it proves nothing about who connected. It is still worth judging - a peer that greets with OUR name, with a bare IP literal, or with something that is not a domain at all, is saying something about itself. Refusing refuses the whole session.
tSmtpCheckHeloEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
const aHeloName: string;
var aAllow: Boolean;
var aCode: Integer;
var aText: string) of object;
proctSmtpCheckSenderEvent
THE REVERSE PATH. aPath may be '' - the null sender, which every host must accept for bounces, and refusing it outright is how a server stops hearing that its own mail failed. Refusing resets the transaction; the connection lives on and may present another sender.
tSmtpCheckSenderEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
const aPath: string;
var aAllow: Boolean;
var aCode: Integer;
var aText: string) of object;
proctSmtpCheckSenderIdentityEvent
WHICH REVERSE PATHS AN AUTHENTICATED ACCOUNT MAY USE beyond its own. A session that authenticated with SMTP AUTH may give MAIL FROM only the address it authenticated as (aAuthorizedAs of OnAuthenticate), the null path, or an address a client certificate on the same connection asserts; anything else is refused with 550 5.7.1 (RFC 6409 sec.6.1, Enforce Submission Rights). This is asked only for a path outside those, and only on a session with SMTP AUTH. aAccount is the authenticated identity, aPath the reverse path as given. Set aAllow True to accept it - an alias the account owns, say. A handler that raises allows nothing: the client gets a 451.
tSmtpCheckSenderIdentityEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
const aAccount, aPath: string;
var aAllow: Boolean) of object;
proctSmtpAuthenticateEvent
The credential, in wiped storage - never a plain string, and never reached over a cleartext channel (the engine refuses the mechanism outright there). Set aAllow True to accept. aAuthorizedAs defaults to aUser and is what the envelope will carry.
tSmtpAuthenticateEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
const aUser: string;
const aPassword: iSecretKey;
var aAuthorizedAs: string;
var aAllow: Boolean) of object;
proctSmtpMessageEvent
A complete message. aData is the dot-unstuffed octets with this hop's Received stamp already on top; aEnvelope is a snapshot that may be kept. aData MAY NOT be kept - it is wiped when the handler returns; copy it. Runs on the reactor I/O thread that delivered the final octet, INLINE, so a handler that blocks holds that thread. Queue the work; do not do it here.
tSmtpMessageEvent = procedure (Sender: TObject;
const aEnvelope: iSmtpEnvelope;
const aData: tBytes;
var aAction: tSmtpMessageAction;
var aCode: Integer;
var aText: string) of object;
proctSmtpClientCertEvent
Peer certificate offered on an mTLS connection. It has ALREADY been verified against the server's trust configuration - a certificate that had not would have failed the handshake - so what is left is authorization: whether THIS peer may relay. aAllow arrives True when RelayForClientCertificate is set and a certificate was presented.
tSmtpClientCertEvent = procedure (Sender: TObject;
const aCertificate: iCertificate;
const aSubjectCN: string;
var aAllow: Boolean) of object;
proctSmtpServerLogEvent
tSmtpServerLogEvent = procedure (Sender: TObject; const aText: string;
aFatal: Boolean) of object;
Routines