POP3Stat

Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO All

Syntax

POP3Stat (server,user,pass[,stsproc,secure {Default zero insecure;1 secure;2 use STARTTLS},verify {Default kTrue}]) Returns waiting-messages

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded, allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

POP3Stat retrieves the number of Internet e-mail messages waiting for a particular user on a specified POP3 server. If an error occurs, the command returns a value less than zero to WaitingMessages. The socket opened to the POP3 server is always closed before the command returns. Possible error codes are listed in the Web Command Error Codes Appendix.

Server is an Omnis Character field containing the IP address or hostname of a POP3 server that will serve e-mail to the client running Omnis. For example: pop3.mydomain.com or 255.255.255.254. If the server is not using the default POP3 port (110, or 995 for a secure connection), you can optionally append the port number on which the server is listening, using the syntax server:port, for example pop3.mydomain.com:1234.

User is an Omnis Character field containing the account that receives the mail on the designated server (usually an account user name, for example, Webmaster).

Pass is an Omnis character field containing the password for the account specified in the User parameter, for example, Secret.

StsProc is an optional parameter containing the name of an Omnis method that POP3Stat calls with status messages. POP3Stat calls the method with no parameters, and the status information in the variable #S1. The status information logs protocol messages exchanged on the connection to the server.

Secure is an optional Boolean parameter which indicates if a secure connection is required to the server. Pass kTrue for a secure connection, in which case the built-in security technology will be used, so on Windows ‘Secure Channel’ (Schannel) is used, on macOS ‘Secure Transport’ is used, and on Linux OpenSSL is used.

POP3Stat also supports an alternative secure option, if you pass secure with the value 2, the connection is initially not secure, but after the initial exchange with the server, POP3Stat issues the STLS POP3 command to make the connection secure if the server supports it (see RFC 2595 for details). Authentication occurs after a successful STLS command.

Verify is an optional Boolean parameter which is only significant when Secure is not kFalse. When Verify is kTrue, the command instructs the installed SSL library to verify the server's identity using its certificate; if the verification fails, then the connection will not be established. You can pass Verify as kFalse, to turn off this verification; in this case, the connection will still be encrypted, but there is a chance the server is an impostor. In order to perform the verification, the installed SSL library uses the Certificate Authority Certificates in the cacerts sub-folder of the secure folder in the Omnis folder. If you use your own Certificate Authority to self-sign certificates, you can place its certificate in the cacerts folder, and the installed SSL library will use it after you restart Omnis.

WaitingMessages is an Omnis Long Integer field which receives an error status, or the number of e-mail messages waiting to be collected on the specified server for the specified account.

Example

# Check to see if there is any e-mail waiting to be received for lUserName
Calculate lServer as 'my.pop3.server'
Calculate lUserName as 'myusername'
Calculate lPassword as 'mypassword'
POP3Stat (lServer,lUserName,lPasswordReturns lWaitingMessages
If lWaitingMessages>0
 # receive mail
End If