Method SMTPClient():connect() Professional

Connects to the SMTP server.

:connect( [<cUsername>], [<cPassword>] ) --> lSuccess
<cUsername> is an optional character string specifying the name of the user to be authenticated.
<cPassword> is a character string specifying an optional password. If a user name is passed in <cUserName>, this parameter becomes mandatory.

The method returns .T. (true) when a connection to the SMTP server is successfully established, otherwise .F. (false) is returned.


This method establishes a connection to the SMTP server for which an SMTPClient object is created. A connection may fail if the object was instantiated with invalid parameters or if the SMTP server does not respond. When the connection is successful, e-mail messages can be sent to the server using the:send() method.

In case the SMTP server requires authentication, the username and password must be specified when calling the :connect() method. The same is true if the port number specified to the :new() method implies an SSL connection. In this case, the parameters <cUsername> and <cPassword> become mandatory.


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.