Method SMTPClient():new() Professional

Creates an instance of the SMTPClient class.

Syntax
:new( <cSmtpServer> , ;
      [<nPort>]     , ;
      [<cFromHost>] , ;
      [<oLogWriter>], ;
      [<nLogLevel>]   ) --> oSMTPClient
Parameters
<cSmtpServer>
This parameter is a character string containing the DNS name or the IP address of the SMTP server the client wants to connect to. For example:
mail.alaska-software.com    DNS name 
199.288.377.466             IP address in dotted octet notation 
<nPort>
<nPort> is a numeric parameter indicating the port number to be used for client and server communication. If no value is passed in this parameter, the port defaults to SMTP standard port 25. The following table lists the port numbers and their meaning when connecting to SMTP servers:
Port numbers for connecting to SMTP servers
Port Number: Description
25 *) SMTP standard port. Communication is unencrypted.
465 Encrypted SSL connection (SMTPS), can only be used with SMTP servers which support SSL.
587 Encrypted Transport Layer Security (TLS) connection which is "upgraded" to using SSL encryption, if supported. Can be used with both SSL and non-SSL SMTP servers.
  1. Default value used for
<cFromHost>
This is the character string containing the domain name of the client. It is used in the initial communication sequence (the HELO command) and identifies the client for the server. If the parameter is omitted, "nowhere.com" is used as the default client domain name.

When cFromHost does not match with the senders e-mail address, some receiving mailserver might reject the mail as spam.

<oLogWriter>
Optionally, a user-defined object can be passed for <oLogWriter>. This object must have the method :write(). This method is called from an SMTPClient object each time the mail server passes character strings containing additional information to the client. When the client wants to log this information, the corresponding data can be processed in the oLogWriter:write() method.
<nLogLevel>
The numerisc values 0, 1 or 2 may be passed for <nLogLevel>. They define the level of log-information routed to the <oLogWriter>object.
Log information levels
<nLogLevel> Description
0 Only errors are reported.
1 Errors and warnings are reported.
2 All communication with the mail server is reported.
Return

The method returns an instance of the SMTPClient class.

Description

The method :new() creates a new SMTPClient object. The parameters passed when calling :new() define basic parameters for operations performed later by the SMTP client object.

The <nPort> parameter has special meaning in terms of how communication occurs between the SMTP server and the client. By default, unencrypted communication is used via the SMTP standard port 25. However, if port 465 is specified via the <nPort> parameter, the client implicitly performs an SSL negotiation right after connecting to the server. This is also known as SMTPS or TLS. If port 587 is used, the client performs an initial SMTP (human readable) handshake before starting SSL negotiation. In the context of SMTP this is known as STARTTLS.

If the server waits on non-standard ports for incoming connections then the method :setConnectionSecurity() can be used to force the type of communication.

Consult the information supplied by your e-mail provider to find out what type of connection is supported by the e-mail server.

Feedback

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.