The built-in functions in the SMTPSession class provide the ability to connect to an SMTP server with a variety of methods and send email and SMTP commands.
The SMTPSession class offers the following functionality:
SMTPSession New() port parameters
Login() Constants
SMTPSession New( String host, Integer port )
Returns a new SMTPSession object
host | - | IP address or domain name of SMTP host. |
port | - | SMTP connection port |
Integer Close()
No parameters. Closes the session.
None |
Integer Connect( [String host] )
The host parameter is optional and if not specified, will connect to the host as specified in the New() function. Otherwise, this host parameter will override whatever host param was used in the New() function. Use this if you do not require authentication to connect to your smtp server.
host | - | IP address or domain name of SMTP server. |
String GetLastError( )
No parameters. Returns an error string for the last error that occured.
Integer GetTimeout()
Gets the timeout value for SMTP commands. The timeout is in milliseconds.
None |
Integer InitContext( SSLOptions options )
Sets the SSL options for a secure connection. You must call this before attempting to do a SecureLogin() call.
options | - | an instance of SSLOptions. |
Integer Login( String username, String password, [Integer loginMethod] )
This function allows authenticated login to an smtp server, with two different methods available, LOGIN_CRAM_MD5 and LOGIN_CLEAR. The loginMethod param is optional and the default is LOGIN_CLEAR.
username | - | username used to login to SMTP server. |
password | - | password used to login to SMTP server. |
loginMethod | - | type of login authentication to use. |
Integer SecureLogin( String hostname, [String username, String password] )
The username/password parameters are optional, use them if your server also requires authentication as well as TLS/SSL. You must have called InitContext() before this.
hostname | - | IP address or domain name of SMTP server. |
username | - | user login on SMTP server |
password | - | user password for SMTP server |
Integer SendCommand( String command, [String arguments] )
Use this to send other raw SMTP commands. The arguments param is optional.
command | - | command to send |
arguments | - |
Integer SendMessage( MailMessage message )
Sends a previously created MailMessage ( an email ).
message | - | MailMessage to send |
Integer SetTimeout( Integer timeout )
Sets the timeout value for SMTP commands. The timeout is in milliseconds.
timeout | - | timeout in milliseconds. |