This page was last modified 5-Jun-2002.

prev | TOC | next

Writing a Custom POP3 Protocol Handler

To register an event handler, enter its information in the JTransit FrontLine configuration XML file nested beneath the server's config element. For example, to register the file mycode/pop3-auth.vtl as the handler for the POP3 protocol's "authorize" event, you would enter:

<jtransit:servers>
  <server protocol="POP3" handler-source-dir="mycode">
    <event-handler event-name="authorize" file="pop3-auth.vtl"/>
  </server>
</jtransit:servers>

You can add as many event-handler's as you need (up to one for each event listed in the reference table below).

The handler itself can be written in any supported template language (ColdFusion, Tango, Velocity, etc.) but should always generate a result that matches the description from the table below. The template can make use of the listed variables as well as all system variables. In the case of Velocity templates, additional objects env, config, clientHostName, serverHostName, log are also available if needed.

For example, a simple POP3 authorize handler written in ColdFusion might look like the following:

<CFQUERY DATASOURCE="mydsn" NAME="result">
  SELECT COUNT(*) FROM Users WHERE username = '#username#'
  AND password = '#password#'
</CFQUERY>
<CFIF result[1,1] GT 0>
  <CFOUTPUT>#result[1,1]#</CFOUTPUT>
<CFELSE>
  invalid login
</CFIF>

Event NameDescription
authorize Called after the username and password are received during a POP3 session, and before any secured commands are accepted.

Variables:
username - the username supplied by the client
password - the password supplied by the client

Returns: The number of waiting messages in the virtual mailbox, or an error message if the credentials are not valid.

list Retrieve a list of the size of each waiting message in the user's virtual mailbox.

Variables: None.

Returns: A comma-separated list of message sizes, in bytes, one for each message. The number of message sizes listed should be the same as that returned by the "authorize" event, and the order should be the same as that indexed by the "retrieve" event.

retrieve Retrieve a single message, including headers, from the user's virtual mailbox.

Variables:
index - the index (starting from 1) of the message to retrieve

Returns: The entire text of the message, including headers. Leading and trailing blank lines will be removed, but note that the headers must end with a blank line.

delete Delete a single message from the user's virtual mailbox.

Variables:
index - the index (starting from 1) of the message to delete

Returns: Nothing if the message was deleted successfully, or an error message if the message could not be deleted.


prev | TOC | next

 Join the JTransit Talk List   |   Email JTransit Support   |   Visit http://jtransit.com/
Copyright ©2002 JTransit, Inc., All Rights Reserved
JTransit, JTransit Compiler, JTransit Runtime, FrontLine and RedLine are Trademarks of JTransit, Inc.
ColdFusion is a trademark of Allaire Corp. Tango is a trademark of Pervasive Software, Inc. WiTango is a trademark of With Enterprise Pty Ltd. Other trademarks are property of the respective trademark owners.