Indy 9
|
TIdPOP3Server = class(TIdTcpServer)
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.
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.
property DefaultPort;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property CheckUser: TIdPOP3ServerLogin;
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.
property OnAPOP: TIdPOP3ServerAPOPCommandEvent;
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.
property OnDELE: TIdPOP3ServerMessageNumberEvent;
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.
property OnLIST: TIdPOP3ServerMessageNumberEvent;
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.
property OnQUIT: TIdPOP3ServerNoParamEvent;
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.
property OnRETR: TIdPOP3ServerMessageNumberEvent;
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.
property OnRSET: TIdPOP3ServerNoParamEvent;
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.
property OnSTAT: TIdPOP3ServerNoParamEvent;
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.
property OnTOP: TIdPOP3ServerTOPCommandEvent;
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.
property OnUIDL: TIdPOP3ServerMessageNumberEvent;
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.