The built-in functions in the POP3Session class provide the ability to connect to a POP3 server with a variety of methods and
retrieve email and send POP3 commands.
The POP3Session class offers the following functionality:

-
POP3Session New ( String host, Integer port )
- Returns a new POP3Session instance, or undefined if an error occured.

POP3Session New() port parameters
-
POP3_PORT
- The standard POP3 port, 110
-
SECURE_POP3_PORT
- The standard Secure POP3 port, 995
ListMessages() Constants
-
LIST_BY_IDS
- List messages by IDs
LIST_BY_UIDS
- List messages by UIDs

-
Integer Close(
)
- Close a connection to an POP3 server.
-
Integer DeleteMessage(
Dynamic messageIndex )
- deletes a message from the POP3 server.
-
String GetLastError()
- Retrieve the a string for the last error code.
-
Integer GetTimeout(
)
- Returns the POP3 timeout in milliseconds.
-
String GetUID(
Integer messageIndex )
- retrieves a UID for a message on the POP3 server.
-
Integer InitContext (
SSLOptions options )
- Used to initialize a security context for SecureLogin().
-
Integer ListMessage(
Dynamic messageIndex )
- retrieves the size of a message from the POP3 server.
-
List ListMessages(
Integer listType )
- retrieves a list of messages from the POP3 server.
-
Integer Login(
String username, String password )
- Initiate a connection to an POP3 server.
-
Integer MessageCount( )
- returns the number of messages for the logged in account.
-
List RetrieveHeader(
Dynamic messageIndex )
- retrieves a message header from the POP3 server.
-
MailMessage RetrieveMessage(
Dynamic messageIndex )
- retrieves a message from the POP3 server.
-
Integer SecureLogin (
String username, String password )
- Initiate a secure connection to an POP3 server.
-
Integer SendCommand(
String command, String arguments )
- Sends raw POP3 commands.
-
Boolean ServerHasUIDs ()
- Returns true if the server supports UIDL command, false otherwise.
-
Integer SetTimeout(
Integer timeout )
- Set POP3 timeout in milliseconds.

New
POP3Session New( String host
,
[Integer port
] )
Returns a new POP3Session object
- Parameters:
-
| host |
- |
IP address or domain name of POP3 host. |
| port |
- |
POP3 connection port, optional and defaults to 110 |
- Returns:
- A new POP3Session object or undefined if there was an error constructing the object.

Close
Integer Close()
No parameters. Closes the session.
- Parameters:
-
- Returns:
- Returns 0 for success and -1 if an error occurred.
DeleteMessage
Integer DeleteMessage(
Dynamic messageIndex
)
The messageIndex parameter can be either an Integer ID or a String UID. Marks the specified message for deletion on the server.
- Parameters:
-
| messageIndex |
- |
either an Integer ID or a String UID of the message to retrieve |
- Returns:
- Returns 0 if successful, -1 if any errors occurred.
GetLastError
String GetLastError(
)
No parameters. Returns an error string for the last error that occured.
- Parameters:
-
- Returns:
- Returns an error string for the last error that occured.
GetTimeout
Integer GetTimeout()
Gets the timeout value for POP3 commands. The timeout is in milliseconds.
- Parameters:
-
- Returns:
- Returns the timeout in milliseconds, -1 if an error occured.
GetUID
String GetUID(
Integer messageIndex
)
Returns the UID for the given message. If no message exists, returns and empty string.
- Parameters:
-
| messageIndex |
- |
ID of the message to retrieve |
- Returns:
- Returns the UID for the given message. If no message exists, returns and empty string.
InitContext
Integer InitContext(
SSLOptions options
)
Sets the SSL options for a secure connection. You must call this before attempting to do a SecureLogin() call.
- Parameters:
-
| options |
- |
an instance of SSLOptions. |
- Returns:
- Returns 0 for success and -1 if an error occurred.
ListMessage
Integer ListMessage(
Dynamic messageIndex
)
The messageIndex parameter can be either an Integer ID or a String UID. Returns the size of the message specified by mesgIndex or -1 if any errors occurred.
- Parameters:
-
| messageIndex |
- |
either an Integer ID or a String UID of the message to retrieve |
- Returns:
- Returns the size of the message specified by mesgIndex or -1 if any errors occurred.
ListMessages
List ListMessages(
[Integer listType
] )
If listType is not specified or LIST_BY_IDS, then it returns a List of the message ids and sizes, one after the other. Ie, 1,234,2,3435,3,5430.
If listType is LIST_BY_UIDS, then it returns a List of the message ids and their UID strings, one after the other, ie, 1,34DF32EAC3,2,64EA32EDC3,3,354456CAE3.
- Parameters:
-
| listType |
- |
type of list to return, either LIST_BY_IDS, or LIST_BY_UIDS. |
- Returns:
- Returns a list of ids.
Login
Boolean Login(
String username
,
String password
)
The client will check server capabilities and authenticate using CRAM-MD5 if available automatically, otherwise, it will login with CLEAR.
- Parameters:
-
| username |
- |
username used to login to POP3 server. |
| password |
- |
password used to login to POP3 server. |
- Returns:
- Returns TRUE for success and FALSE if an error occurred.
MessageCount
Integer MessageCount(
)
No parameters. Returns the number of messages for the logged in user on the POP3 server.
- Parameters:
-
- Returns:
- Returns the number of messages for the logged in user on the POP3 server.
RetrieveHeader
List RetrieveHeader(
Dynamic messageIndex
)
The messageIndex parameter can be either an Integer ID or a String UID. Returns a List composed of the key/value string pairs found in the header of the given message. The return value will be Undefined if no message exists at that index. Ie, key1, value1, key2, value2, etc.
- Parameters:
-
| messageIndex |
- |
either an Integer ID or a String UID of the message to retrieve |
- Returns:
- Returns a List for the given mesgIndex. The return value will be Undefined if no message exists at that index.
RetrieveMessage
MailMessage RetrieveMessage(
Dynamic messageIndex
)
The messageIndex parameter can be either an Integer ID or a String UID. Returns a MailMessage class for the given messageIndex. The return value will be Undefined if no message exists at that index.
- Parameters:
-
| messageIndex |
- |
either an Integer ID or a String UID of the message to retrieve |
- Returns:
- Returns a MailMessage class for the given mesgIndex. The return value will be Undefined if no message exists at that index.
SecureLogin
Integer SecureLogin(
String username
,
String password
)
Does an SSL secure login. You must have called InitContext() before this.
- Parameters:
-
| username |
- |
user login on POP3 server |
| password |
- |
user password for POP3 server |
- Returns:
- Returns 0 for success and -1 if an error occurred.
SendCommand
Integer SendCommand(
String command
,
[String arguments
] )
Use this to send other raw POP3 commands. The arguments param is optional.
- Parameters:
-
| command |
- |
command to send |
| arguments |
- |
command arguments to send |
- Returns:
- Returns 0 for success and -1 if an error occurred.
ServerHasUIDs
Boolean ServerHasUIDs()
Returns TRUE if the server supports UIDL command, FALSE otherwise
- Parameters:
-
- Returns:
- TRUE if the server supports UIDL command, FALSE otherwise.
SetTimeout
Integer SetTimeout(
Integer timeout
)
Sets the timeout value for POP3 commands. The timeout is in milliseconds.
- Parameters:
-
| timeout |
- |
timeout in milliseconds. |
- Returns:
- Returns 0 for success and -1 if an error occurred.