POP3Connect

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

Syntax

POP3Connect (server,username,password[,stsproc,secure {Default zero insecure;1 secure;2 use STARTTLS},verify {Default kTrue}]) Returns socket

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.

POP3Connect establishes a connection to a POP3 server. If POP3Connect succeeds, it returns the socket opened to the POP3 server. You can use this socket with the other POP3 commands which require a socket argument. If an error occurs, POP3Connect returns an error code, which is less than zero. Possible error codes are listed in the Web Command Error Codes Appendix.

Note that it is essential that you call POP3Disconnect when you have finished using the connection to the POP3 server.

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.

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

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

StsProc is an optional parameter containing the name of an Omnis method that POP3Connect calls with status messages. POP3Connect 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.

POP3Connect 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, POP3Connect 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.

Socket is an Omnis Long integer field which receives the socket for the new connection. If an error occurs, POP3Connect returns an error code with a value less than zero. Possible error codes are listed in the Web Command Error Codes Appendix.

Example

# Establish a connection to the POP3 server lServer for user
# lUsername using the password lPassword
Calculate lServer as 'my.pop3.server'
Calculate lUserName as 'myusername'
Calculate lPassword as 'mypassword'
POP3Connect (lServer,lUserName,lPasswordReturns iSocket