File 'net/smtp/smtp.cls' (part of 'Pool_Net')

Description (short)
SMTP conection management
Written by
Andreas Kupries
Description
Management of SMTP connections
Keywords
SMTP, management of SMTP connections, close smtp connection, open smtp connection, send mail

Class 'smtpConnection'

Description
Instances of this class manages a connection to an smtp demon. The actual execution of command-reply sequences is delegated to sequencer classes derived from smtpSequencer. The methods encapsulating the access to these low-level exchanges are Open, Close, Data and Prepare. Based on these primitives a stateful high-level interface is formed (open, close and put). These methods call the appropriate primitives according to the state of the connection. I expect, that put will be the most used method of this class.
Options
helo
maxtries
retrydelay
host
timeout
progress
blocksize
Methods
public
ClearSocket ()
Close (completionMethod)
Data (completionMethod message msgIsString)
Finish (seq)
HandleOpened (seq)
HandlePrepared (seq)
Open (completionMethod)
Prepare (completionMethod from to)
SetSock (s)
close (args)
errorInfo ()
open (args)
put (args)
smtpConnection ()
state ()
~smtpConnection ()
Membervariables
public
sock
state
error
opState

Options

-helo
Specifies the string to use as argument for the HELO command sent to the demon after its greeting.
-maxtries
Specifies the maximum allowed number of trials to connect. Defaults to 1.
default value: 1
-retrydelay
Specifies the time to wait (in milliseconds) after a failure before doing the next try. Defaults to 10 seconds.
default value: 10000
-host
Specifies the host the demon to connect to resides on. Defaults to 'localhost'.
default value: localhost
-timeout
defines the number of milliseconds to wait before aborting a smtp command without having a response.
-progress
If not empty, a command to evaluate with current connection and number of bytes transfered so far as arguments.
-blocksize
Companion option to progress, optional. Defines the size of the blocks to transfer between invocations of progress. Ignored if progress is empty.
default value: 1024

Methods

ClearSocket ()

Closes the connection to the smtp demon described by this object.

Close (completionMethod)

Close connection to the smtp demon described by this object. Configures a smtpCloseSeq object and then delegates the work to it.
Argument: completionMethod The method to call after completion of the low-level sequencer.

Data (completionMethod message msgIsString)

Executes the transfer of a message body via SMTP protocol. Configures a smtpDataSeq object and then delegates the work to it.
Argument: completionMethod The method to call after completion of the low-level sequencer.
Argument: message Handle of the channel containing the message to send over (or the message itself (msgIsString = TRUE)).
Argument: msgIsString (= 0) A boolean value. Set if message is no channel handle, but the message itself.

Finish (seq)

Called by all highlevel sequencers at the end of their operation. Retrieves the state of the invoking sequencers and changes the state of the connection accordingly. Detection of errors cause the shutdown of the connection to the demon.
Argument: seq (= {}) Handle of the sequencer finishing its operation. Empty if the requested operation was a no-op. In that case it was called immediately too.

HandleOpened (seq)

Called after completion of the open sequencer seq during a put transaction. Initiates the preparation transaction if no error came back to us.
Argument: seq Handle of the finishing sequencer.

HandlePrepared (seq)

Called after completion of the prepare sequencer seq. Initiates the data transfer if no error came back to us
Argument: seq Handle of the finishing sequencer.

Open (completionMethod)

Opens a connection to the smtp demon described by this object. Configures a smtpOpenSeq object and then delegates the work to it.
Argument: completionMethod The method to call after completion of the low-level sequencer.

Prepare (completionMethod from to)

Prepares the transfer of a mail message by specifying sender and recipients to the smtp demon described by this object. Configures a smtpPrepareSeq object and then delegates the work to it.
Argument: completionMethod The method to call after completion of the low-level sequencer.
Argument: from The address of the sender.
Argument: to A list containing the addresses of the intended receivers.

SetSock (s)

Accessor method, used by the smtpOpenSeq sequencer to transfer information about the channel representing the connection to the smtp demon.
Argument: s The handle of the channel representing the connection to the smtp demon.

close (args)

Closes the connection to the smtp demon. The low-level method Close is used to execute the task. Configured by a list of option/value pairs.
Argument: args List of option/value pairs.
Recognized and required is -command.
It defines a script to be executed after the transaction completed.

errorInfo ()

Returns: the error information of the SMTP connection. Valid only in case of state = error.

open (args)

Opens the connection to the smtp demon. The low-level method Open is used to execute the task. Configured by a list of option/value pairs.
Argument: args List of option/value pairs.
Recognized and required is -command.
It defines a script to be executed after the transaction completed.

put (args)

Send a mail to the smtp demon. The low-level methods Prepare and Data are used to execute the task. Configured by a list of option/value pairs. Will open the connection if necessary (via Open).
Argument: args List of option/value pairs.
Recognized are -command, -message, -from, -to and -string.
Required are -command, -message, -from and -to.
-command specifies a script to be executed after completion.
-message is interpreted as channel containing the message to be send, or the message itself (if -string is set to true).
-from specifies the sender of the mail.
-to is interpreted as a list of recipient addresses.
-string is boolean value indicating wether -message is the channel containing it (false), or the message itself (true). This is optional and defaults to false.

smtpConnection ()

Constructor. Just logs the event.

state ()

Returns: the state of the SMTP connection.

~smtpConnection ()

Destructor. Closes an active socket and logs the event.


Membervariables

sock
The handle of the channel controlled by this object
state
The state of the last executed command.
error
The error message of the last executed, failed command.
opState
Contains the state of the currently running highlevel transaction.

Generated by AutoDoc 2.4 at 09/14/2000, invoked by Andreas Kupries