Indy 9
TIdPOP3Server
Hierarchy, Properties, Methods, Events, See Also, Unit: IdPOP3Server
Implements a multi-threaded POP3 server.
TIdPOP3Server = class(TIdTcpServer)
Unit
IdPOP3Server
Description
TIdPOP3Server is a TIdTcpServer descendant that implements a multi-threaded server using the Post Office Protocol version 3 (POP3), as described in the Internet Standards document:

TIdPOP3Server provides the capabilities needed to allow simultaneous client connections to access a POP3 maildrop and retrieve undelivered mail messages on the server.

TIdPOP3Server is not intended to provide extensive manipulation operations of mail on the server; normally, mail is downloaded and then deleted. Use TIdIMAP4 and TIdIMAP4Server when a more advanced (and complex) mail protocol is required.

TIdPOP3Server provides a dual implementation capability, mirroring the options available in TIdTCPServer, using the TIdTCPServer.OnExecute event handler or through the use of the TIdCommandHandlers collection.

  • USER

  • PASS

  • LIST

  • RETR

  • DELE

  • QUIT

  • APOP

  • STAT

  • NOOP

  • RSET

  • TOP

  • UIDL

Use CommandHandlers and CommandHandlerEnabled to provide finer control over the implementation of the commands and event handlers for threaded client connections to the POP3 server.

TIdPOP3Server provides methods that allow a command handler to trigger event handlers that implement the specifics of accessing the mailstore and file system for the server. TIdPOP3Server also utilizes TIdPOP3ServerThread to handle threaded client connections to the server, and allow tracking of identity, authentication, and state for the client connections to the server.


TIdPOP3Server.DefaultPort
TIdPOP3Server, See Also
Default port number used to listen doer client connections.
property DefaultPort;
Description
DefaultPort is a publishes integer property in TIdPOP3Server, and represents the port used to listen for new connections to the POP3 server. DefaultPort is assigned to the Bindings used for the server. The initial value for DefaultPort is IdPORT_POP3, as assigned in the Create constructor.

TIdPOP3Server.Create
TIdPOP3Server, See Also
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
TComponent - Owner of the object instance.
Description
Create is the constructor for the object instance, and calls the inherited Create method. Create assigns TIdPOP3ServerThread as the class type for threaded client connections to the server, and sets the value for DefaultPort to IdPORT_POP3 as required by the POP3 protocol. Create also sets the default values used in Greeting and ReplyUnknownCommand.

TIdPOP3Server.Destroy
TIdPOP3Server, See Also
Frees the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy calls the inherited method prior to exiting.

TIdPOP3Server.CheckUser
TIdPOP3Server, See Also
Implements identifying and authenticating a client connection.
property CheckUser: TIdPOP3ServerLogin;
Description
CheckUser is a TIdPOP3ServerLogin property that represents the event handler triggered to implement identifying and authenticating a client connection after the POP2 PASS command. CheckUser is called from the command event handler that implements the TIdCommand for PASS for the threaded client.

Note: Assign a procedure to the event handler to allow responding to the TIdPOP3ServerLogin event. The procedure is responsible for setting the session state in the TIdPOP3ServerThread.State instance depending on success or failure of the process. The procedure does not have to write positive or negative POP3 responses to the client connection.


TIdPOP3Server.OnAPOP
TIdPOP3Server, See Also
Implements alternative authentication for POP3 client connections.
Description
OnAPOP is a TIdPOP3ServerAPOPCommandEvent property that represents the event handler signalled when a threaded client connection performs the POP3 APOP command verb. OnAPOP allows the server to implement an alternate method of authentication which does not involve sending a password as clear text over the network.

OnAPOP is triggered by the command event handler that implements the TIdCommand for APOP for the threaded client connection. OnAPOP must verify that the mailbox identifier and digest from the client connection are valid.

AMailboxID is the POP3 account name (or mailbox) accessed by the client connection.

ADigest is the 16-octet hexadecimal MD5 Message Digest calculated by applying the MD5 algorithm specified in RFC 1321 to a string consisting of the timestamp (including angle-brackets) followed by the shared APOP secret for the client connection.

Note: Assign a procedure to the event handler to allow responding to the event notification. If the digest is correct, the event handler is responsible for write a positive POP3 response to the client connection, and setting the TIdPOP3ServerThread.State to the correct value. Negative POP3 responses are written by the command event handler that triggers OnAPOP when TIdPOP3ServerThread.State does not contain the value Auth on entry, and the value Trans on exit.


TIdPOP3Server.OnDELE
TIdPOP3Server, See Also
Implements marking a message for deletion in the POP3 mail store.
Description
OnDELE is a TIdPOP3ServerMessageNumberEvent property that represents the event handler signalled when a threaded client connection performs the POP3 DELE command verb. OnDELE allows the server to implement marking a specified message for deletion in the mailstore on the server. OnDELE must verify that the specified message number is not already deleted in the mailstore. OnDELE defers physical removal of the message to the OnQUIT event handler.

OnDELE is triggered by the command event handler that implements the TIdCommand for DELE for the threaded client connection. OnDELE

Note: Assign a procedure to the event handler to allow responding to the event notification. The OnDELE event handler is not triggered if the TIdPOP3ServerThread.State property contains a value other than Trans. The event handler is responsible for writing positive POP3 responses; Negative POP3 responses are written by the command event handler that triggers OnDELE when TIdPOP3ServerThread.State does not contain the value Trans on entry, or encounters an exception in the event handler.


TIdPOP3Server.OnLIST
TIdPOP3Server, See Also
Implements generating a list of messages in the server mail store.
Description
OnLIST is a TIdPOP3ServerMessageNumberEvent property that represents the event handler signalled when a threaded client connection performs the POP3 LIST command verb. OnLIST allows the server to implement generation of a listing containing information about one or more messages in a server mailstore.

In order to simplify parsing POP3 listings, all POP3 servers are required to use a common format for listings. A scan listing consists of the message-number of the message, followed by a single space and the exact size of the message in octets. Additional information may follow the the message size in the scan listing, and is dependent on the server implementation. It is not, however, encouraged. Each line in the listing must end with a CRLF pair.

Note: Messages marked for deleteion are not included in a listing.

OnLIST is triggered by the command event handler that implements the TIdCommand for LIST for the threaded client connection.

Note: Assign a procedure to the event handler to allow responding to the event notification. The OnLIST event handler is not triggered if the TIdPOP3ServerThread.State property contains a value other than Trans. The event handler is responsible for writing the content for the listing and other positive POP3 responses; Negative POP3 responses are written by the command event handler that triggers OnLIST when TIdPOP3ServerThread.State does not contain the value Trans on entry, or the event handler is unassigned.


TIdPOP3Server.OnQUIT
TIdPOP3Server, See Also
Implements closing and housekeeping for a POP3 session.
property OnQUIT: TIdPOP3ServerNoParamEvent;
Description
OnQUIT is a TIdPOP3ServerNoParamEvent property that represents the event handler signalled when a threaded client connection performs the POP3 QUIT command verb. OnQUIT allows the server to implement processing required to release resources acquired during POP3 session, remove messages marked for deletion, and close the client connection.

OnQUIT is triggered by the command event handler that implements the TIdCommand for QUIT for the threaded client connection.

Note: Assign a procedure to the event handler to allow responding to the event notification. The OnQUIT event handler is not triggered if the TIdPOP3ServerThread.State property contains a value other than Trans. The event handler is responsible for writing the POP3 goodbye response, and setting the TIdPOP3ServerThread.State to Update for the POP3 client session.


TIdPOP3Server.OnRETR
TIdPOP3Server, See Also
Implements retrieval of messages from the server mail store.
Description
OnRETR is a TIdPOP3ServerMessageNumberEvent property that represents the event handler signalled when a threaded client connection performs the POP3 RETR command verb.

OnRETR allows the server to retrieve the specified message number from the server mail store. OnRETR must write the RFC-compliant contents of the message to the connection for the POP3 client. OnRETR is responsible for writing the initial +OK response that includes the message size, the contents of the RFC message, and the terminating '.' for the retrieved message.

Note: The message number cannot refer to a message marked for deletion, or a negative POP3 response should be returned from the event handler. OnRETR is not triggered when TIdPOP3ServerThread.State contains a value other than Trans. Negative POP3 responses are written by the RETR command handler when TIdPOP3ServerThread.State is invalid, or the OnRETR event handler has not been assigned.


TIdPOP3Server.OnRSET
TIdPOP3Server, See Also
Implements resetting a POP3 client session.
property OnRSET: TIdPOP3ServerNoParamEvent;
Description
OnRSET is a TIdPOP3ServerNoParamEvent property that represents the event handler signalled when a threaded client connection performs the POP3 RSET command verb. OnRSET allows the server to implement processing required to unmark any messages marked for deletion from the server mail store for the client connection.

OnRSET is triggered by the command event handler that implements the TIdCommand for RSET for the threaded client connection. Note: OnRSET is not triggered for a client connection where TIdPOP3ServerThread.State contains a value other than Trans.

OnRSET is responsible for writing the positive POP3 response to the client connection after restoring messages marked for deletion; Negative POP3 responses are written by the RSET command handler when TIdPOP3ServerThread.State contains a value other than Trans or the OnREST event handler has not been assigned.


TIdPOP3Server.OnSTAT
TIdPOP3Server, See Also
Implements a maildrop status listing for threaded client connections.
property OnSTAT: TIdPOP3ServerNoParamEvent;
Description
OnSTAT is a TIdPOP3ServerNoParamEvent property that represents the event handler signalled when a threaded client connection performs the POP3 STAT command verb. OnSTAT allows the server to implement processing required to generate a status listing for the maildrop for for the client connection.

To simplify POP3 client parsing, the POP3 server is required to use a common format for drop listings. The positive response consists of "+OK" followed by a single space, the number of messages in the maildrop, a single space, and the size of the maildrop in octets. Additional server-dependent information may be included in the drop listing, but it is not encouraged. The drop listing is terminated by the CRLF pair.

Note: Messages marked for deletion should not be included in the message count or total message size for the maildrop.

OnSTAT is triggered by the command event handler that implements the TIdCommand for STAT for the threaded client connection. Note: OnSTAT is not triggered for a client connection where TIdPOP3ServerThread.State contains a value other than Trans.

OnSTAT is responsible for writing the positive POP3 response to the client connection; Negative POP3 responses are written by the STAT command handler when TIdPOP3ServerThread.State contains a value other than Trans or the OnSTAT event handler has not been assigned.


TIdPOP3Server.OnTOP
TIdPOP3Server, See Also
Implements a maildrop status listing for threaded client connections.
Description
OnTOP is a TIdPOP3ServerTOPCommandEvent property that represents the event handler signalled when a threaded client connection performs the POP3 TOP command verb. OnTOP allows the server to implement the optional POP3 command, and performs processing required to extract message headers and the specified number of body lines for the indicated message number.

OnTOP is responsible for generating the initial Positive POP3 response, followed by message headers, a blank line, the number of body lines requested, and the terminating '.' character. If the number of lines requested by the POP3 client is greater than the number of lines in the body, then the POP3 server sends the entire message.

Note: It is recommended to implement support for the TOP command. Messages marked for deletion should not be included in the TOP listing.

OnTOP is triggered by the command event handler that implements the TIdCommand support for TOP for the threaded client connection. Note: OnTOP is not triggered for a client connection where TIdPOP3ServerThread.State contains a value other than Trans, or the event handler has not been assigned.

OnTOP is responsible for writing the positive POP3 response to the client connection; Negative POP3 responses are written by the TOP command handler when TIdPOP3ServerThread.State contains a value other than Trans or the OnTOP event handler has not been assigned.


TIdPOP3Server.OnUIDL
TIdPOP3Server, See Also
Description
OnUIDL is a TIdPOP3ServerMessageNumberEvent property that represents the event handler signalled when a threaded client connection performs the POP3 UIDL command verb. OnUIDL allows the server to implement the optional POP3 command, and performs processing required to generate the unique identifier listing for one or more messages in the mail store for the client connection.

OnUIDL is responsible for generating the initial Positive POP3 response, followed by one or more lines containing information for the specified message(s). If no message number is specified, the response will contain multiple unique identifier lines.

To simplify POP3 client parsing, all POP3 servers are required to use a cokmon format for unique-id listings. A unique-id listing consists of the message-number of the message, followed by a single space and the unique-id of the message. No information follows the unique-id in the unique-id listing.

The unique-id of a message is an arbitrary server-determined string, consisting of one to 70 characters in the range 0x21 to 0x7E, which uniquely identifies a message within a maildrop and which persists across sessions. This persistence is required even if a session ends without entering the UPDATE state. The server should never reuse an unique-id in a given maildrop, for as long as the entity using the unique-id exists.

Note: Messages marked for deletion are not included in a UIDL listing. It is recommended to implement support for the UIDL command. It is generally preferable for server implementations to store arbitrarily assigned unique-ids in the maildrop, but it is permitted for unique-ids to be calculated as a hash of the message. Clients should be able to handle a situation where two identical copies of a message in a maildrop have the same unique-id.

OnUIDL is triggered by the command event handler that implements the TIdCommand support for UIDL for the threaded client connection. Note: OnUIDL is not triggered for a client connection where TIdPOP3ServerThread.State contains a value other than Trans, or the event handler has not been assigned.

OnUIDL is responsible for writing the positive POP3 response to the client connection; Negative POP3 responses are written by the UIDL command handler when TIdPOP3ServerThread.State contains a value other than Trans or the OnTOP event handler has not been assigned.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.