MailSend.mesa
Copyright Ó 1988, 1989, 1991 by Xerox Corporation. All rights reserved.
Doug Terry, October 21, 1988 4:46:21 pm PDT
Wes Irish, January 26, 1989 2:10:19 pm PST
Willie-Sue, July 31, 1989 2:29:24 pm PDT
Operations for sending electronic mail messages.
DIRECTORY
Rope USING [ROPE],
MailBasics USING [ItemType, RName, RNameList],
MailUtils USING [Credentials];
MailSend: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
These defs allow clients to inject messages into the mail system. They are designed so that they can be used by multiple processes creating different messages; the state of creation of a single message is represented by a "Handle". The interface is also designed so that it may be implemented either by transmission over the network to a remote mail server, or by calls on a local mail server.
SendingCredentialsList: TYPE = LIST OF SendingCredentials;
SendingCredentials: TYPE = REF SendingCredentialsRec;
SendingCredentialsRec: TYPE = RECORD [
credentials: MailUtils.Credentials,
authenticated: BOOL ¬ FALSE,
returnTo: MailBasics.RName
];
nullCredentials: SendingCredentials = NIL;
MailSendHandle: TYPE = REF MailSendHandleObject;
MailSendHandleObject: TYPE ~ RECORD [
credentialsList: SendingCredentialsList,
recipients: MailBasics.RNameList,
lastRecipient: MailBasics.RNameList,
bodyParts: LIST OF BodyPartInfo,
lastBodyPart: LIST OF BodyPartInfo,
nBodyParts: CARDINAL ¬ 0
];
BodyPartInfo: TYPE = REF BodyPartInfoObject;
BodyPartInfoObject: TYPE = RECORD [
type: MailBasics.ItemType,
data: ROPE ¬ NIL
];
MailSendProcsRef: TYPE = REF MailSendProcs;
MailSendProcs: TYPE = RECORD [
which: ATOM,
Send: PROC[msH: MailSendHandle, validate, sendEvenIfInvalidNames: BOOL]
RETURNS [sent: BOOL, failureReason: ROPE, invalidNames: MailBasics.RNameList]
];
Create: PROC RETURNS [msH: MailSendHandle];
For any one Handle, the following calls should be made in the following order:
StartSend,
AddRecipient, AddRecipient, AddRecipient, . . .
StartItem, (AddToItem, AddToItem, . . .), StartItem, (...), . . .
Send
Abort may be called at any point to abandon the sequence. A Handle may be re-used. "Abort" happens implicitly if needed sometime after the last reference to the Handle goes away.
StartSend: PROC [msH: MailSendHandle, credentialsList: SendingCredentialsList];
Starts a message.
If any message is pending on msH it is first Aborted.
If credentialsList is NIL it will be defaulted to credentials of the currently logged in user, otherwise it is a list of credentials for the transport(s) that the user will request later in Send. It is ok to specify credentials for transports that aren't used but you should not specify more than one credential for a single transport.
AddRecipient: PROC [msH: MailSendHandle, recipient: MailBasics.RName];
Adds to the recipient list.
StartItem: PROC [msH: MailSendHandle, type: MailBasics.ItemType];
Start a message body item.
AddToItem: PROC [msH: MailSendHandle, buffer: ROPE];
Add the data to the current message body item.
Send: PROC [msH: MailSendHandle, validate, sendEvenIfInvalidNames: BOOL, transport: ATOM ¬ $any]
RETURNS [sent: BOOL, failureReason: ROPE, invalidNames: MailBasics.RNameList];
Send the message:
msH should hold the message to be sent.
If validate=TRUE then the message will only be sent if all names are valid.
transport specifies the transport that the user wants.
sent reflects if the message was actually sent or not.
failureReason indicates why Send failed (if sent = FALSE).
invalidNames will contain all name known to be invalid at posting time. validate controls whether invalidNames prevents sending or not.
NOTE: The message in msH is left undisturbed. You can call Send again, possibly with a different transport, if so desired (such as the first send failed).
May raise SendFailed
Abort: PROC [msH: MailSendHandle];
Abandon the message. May be called at any time. "Flushes" the msH so that you may start another message.
RegisterMailSendProcs: PROC[newProcs: MailSendProcsRef];
GetRegisteredSendProcsList: PROC RETURNS[LIST OF MailSendProcsRef];
in case anyone wants them
GetRegisteredMailSendProcs: PROC[which: ATOM] RETURNS[MailSendProcsRef];
END.