OScript API/Built-in Package Index |
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:
Login using clear text
Login using CRAM_MD5
Login using an OAuth2 token
The standard Secure SMTP port, 465
The standard SMTP port, 25
Returns a new SMTPSession instance, or undefined if an error occured.
Returns a new SMTPSession instance using a SSL socket, or undefined if an error occured.
Close a connection to an SMTP server.
Connect to an SMTP server.
Retrieve the string for the last error code.
Returns the SMTP timeout in milliseconds.
Used to initialize a security context for SecureLogin().
Initiate a connection to an SMTP server.
Initiate a secure connection to an SMTP server.
Sends raw SMTP commands.
Sends a mail message.
Set SMTP timeout in milliseconds.
Login using clear text
Login using CRAM_MD5
Login using an OAuth2 token
The standard Secure SMTP port, 465
The standard SMTP port, 25
Returns a new SMTPSession object
IP address or domain name of SMTP host.
SMTP connection port; default value is 25.
A new SMTPSession object or undefined if there was an error constructing the object.
Returns a new SMTPSession object using a SSL socket.
IP address or domain name of SMTP host.
SMTP connection port
SSL options
A new SMTPSession object using a SSL socket or undefined if there was an error constructing the object.
No parameters. Closes the session.
Returns 0 for success and -1 if an error occurred.
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.
IP address or domain name of SMTP server.
Returns 0 for success and -1 if an error occurred.
No parameters. Returns an error string for the last error that occured.
Returns an error string for the last error that occured.
Gets the timeout value for SMTP commands. The timeout is in milliseconds.
Returns the timeout in milliseconds, -1 if an error occured.
Sets the SSL options for a secure connection. You must call this before attempting to do a SecureLogin() call.
an instance of SSLOptions.
Returns 0 for success and -1 if an error occurred.
This function allows authenticated login to an SMTP server, with three different methods available, LOGIN_CRAM_MD5, LOGIN_CLEAR, and LOGIN_XOAUTH2. The loginMethod param is optional and the default is LOGIN_CLEAR.
username used to login to SMTP server.
user password or authentication token for SMTP server.
type of login authentication to use: one of LOGIN_CRAM_MD5, LOGIN_CLEAR, or LOGIN_XOAUTH2.
Returns 0 for success and -1 if an error occurred.
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.
IP address or domain name of SMTP server.
user login on SMTP server.
user password or authentication token for SMTP server.
type of login authentication to use: one of LOGIN_CRAM_MD5, LOGIN_CLEAR, or LOGIN_XOAUTH2.
Returns 0 for success and -1 if an error occurred.
Use this to send other raw SMTP commands. The arguments param is optional.
command to send
arguments to include with the command
Returns 0 for success and -1 if an error occurred.
Sends a previously created MailMessage.
MailMessage to send
The list of recipient addresses that were rejected from smtp server
Returns 0 for success and -1 if an error occurred. For backwards
compatibility, if the optional badAddresses argument is omitted, then if any one of the recipient
addresses within the message is rejected by the SMTP server for the session, then an error has occurred,
-1 is returned and the details (as with any error) can be obtained via GetLastError. If the RecArray
badAddresses argument is provided, then, rather than rejecting the message upon the first rejection of a
recipient address, the information regarding the rejected address is placed in a Record in badAddresses
and the next recipient address is provided to the SMTP server. Provided at least one valid address is
present, then the message will be sent to all valid addresses, and the information about the rejected
addresses will be available to the calling function via the Record(s) in the badAddresses argument.
The columns of such a Record (which are also added to the RecArray if they do not already exist) are
"address" [a String value containing the address that was rejected by the SMTP server], "status" [an
Integer value containing the numeric code with which the address was rejected], and "response" [a String
value containing the full text of the rejection]. Note that the "status" value is extracted from the
"response" value for convenience.
Sets the timeout value for SMTP commands. The timeout is in milliseconds.
timeout in milliseconds.
Returns 0 for success and -1 if an error occurred.
Copyright © 2023 OpenText Corporation. All rights reserved. |