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


Home | Packages | Files | Procedures | Classes | Keywords | External packages


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
blocksize, helo, host, maxtries, progress, retrydelay, timeout
Membervariables
error, opState, sock, state
Methods
ClearSocket, Close, Data, Finish, HandleOpened, HandlePrepared, Open, Prepare, SetSock, close, errorInfo, open, put, smtpConnection, state, ~smtpConnection

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

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

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: completionMethodThe 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: completionMethodThe method to call after completion of the low-level sequencer.
Argument: messageHandle 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: seqHandle 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: seqHandle 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: completionMethodThe 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: completionMethodThe method to call after completion of the low-level sequencer.
Argument: fromThe address of the sender.
Argument: toA 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: sThe 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: argsList of option/value pairs.&p Recognized and required is -command.&p 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: argsList of option/value pairs.&p Recognized and required is -command.&p 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: argsList of option/value pairs.&p Recognized are -command, -message, -from, -to and -string.&p Required are -command, -message, -from and -to.&p -command specifies a script to be executed after completion.&p -message is interpreted as channel containing the message to be send, or the message itself (if -string is set to true).&p -from specifies the sender of the mail.&p -to is interpreted as a list of recipient addresses.&p -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.


Generated by AutoDoc 2.1 at 02/20/1999, invoked by Andreas Kupries