DELIVER DELIVER is an adjunct to VMS MAIL which makes it possible for incoming mail messages to be handled and processed automatically based on information provided in a user-supplied file. Different actions can be taken based on a message's address, subject or contents. These actions include delivering the message, forwarding the message or even invoking a DCL command script to perform some complex operation. Any actions taken occur immediately upon receipt of the message; the user does not need to log in for DELIVER to operate. The MAIL.DELIVERY file controls DELIVER and tells it how to handle each message. A MAIL.DELIVERY file consists of a series of directives with one directive on each line of the file. Each directive specifies how a certain kind of message is to be handled. A particular directive may or may not apply to a given message. An attempt is made to apply every directive in the MAIL.DELIVERY file to each message, thus more than one directive may apply to (and more than one action may be the result of) a single message. Any line in the file which begins with a semicolon or an exclamation point is considered to be a comment and is ignored. A directive line consists of the following items in order from left to right: Items must be delimited by one or more spaces or tabs. Quoted strings (use double quotes, not single quotes) are allowed as single items; the quotes are removed from the items as they are read. A double quote can be obtained by using two double quotes with no space between them. This form of quote handling is consistent with that of VMS DCL. The and items are both optional and may be omitted if the requires no parameters. The first five items are mandatory and must appear on every directive line. 3 Applicability The , , and items determine whether or not the directive applies to a particular message. A string comparison is performed between the patterns , and and the "From:", "To:" and "Subject:" fields of the message header respectively. The comparison is not case sensitive. The usual VMS wildcard characters ("*" and "%") can be used in the patterns. The pattern "*" will match anything. Once the comparisons have been performed, the item determines if the directive should be applied to the message. Only the first character of is significant. It should be one of the following: A - always apply this directive; ignore the results of the comparisons. Note that this directive does not count as an applied directive (see O, B, and E below). X - never apply this directive; ignore the results of the comparisons. T - apply this directive if the patterns all matched. F - apply this directive if the patterns did not all match. O - apply this directive if the patterns all matched and no previous directive has been applied to the message. Directives that used the A accept item don't count as having been applied. B - apply this directive if a pattern did not match and no previous directive has been applied to the message. Directives that used the A accept item don't count as having been applied. E - this directive applies if all the patterns matched OR no other directive has been applied so far. Directives that used the A accept item don't count as having been applied. Any character whatsoever is legal: Y is the same as T, N is the same as F, question mark is the same as O, Q is the same as B and all other characters are the same as X. Directives are tested in the order they appear in the MAIL.DELIVERY file. For example, suppose JIM sends a message to BOB. The subject line of the message is "Re: Mooses". BOB's MAIL.DELIVERY file contains the following lines (the function of the last two columns of each line, the and items, is described later): "FRED *" * * T Q "JIM *" * * T A JIM.LOG * * *mooses* T A MOOSE.LOG * * * O A OTHER.LOG * * * A D The first directive in the file does not apply since the message is not from FRED. The second and third directives both apply since JIM is the sender and the subject line contains the string "mooses". The fourth directive's patterns all apply, but a preceeding directive has applied, so it does not apply. The final directive applies since it would apply to any message. The result is that three directives apply to this message, and thus three separate actions are taken in processing the message. Note: The patterns "FRED *" and "JIM *" are useful since VMS MAIL lets users set up personal name fields which become part of the "From:" field of the message -- the personal name is enclosed in quotes and appended to the user name. Depending on personal name fields for message handling is not a good idea since some users have a tendency to change personal names frequently and without warning. The use of the space followed by an asterisk will match any personal name field a user sets up; the result is a MAIL.DELIVERY file which is insensitive to personal names. If none of the directives in the file are found to apply to and process the message in some way, the message is just delivered normally. The effect is equivalent to the following directive: * * * A D 3 Actions The and items specify what action is taken when a directive is applied to a message. The first character of specifies what type of action to take. The legal characters for and what they do are: A - append the body (or contents) of the message to a file. The item specifies the file name. The file need not already exist: if necessary, it will be created. The recipient must have write access to the file, if it exists, and write access to its directory if it needs to be created; DELIVER grants the user no special file access privileges. C - copy the body of the message to a file whose name is . Write access to the directory where the file is to be created is required. D - deliver the message normally. Under VMS V5.0 or later, this is done using the FOLDER utility. is the name of the folder the message is to be placed in. If is omitted the message is placed in the NEWMAIL folder by default. Under earlier versions of VMS, the message is placed in the NEWMAIL folder using VMS MAIL. is ignored. If is specified it gives the name of the mail file containing the specified folder. If is omitted the user's default mail file is used. H - append the header (in conventional VMS MAIL format) and the body (or contents) of the message to a file. One blank line is written between the header and the body. The item specifies the file name. The file need not already exist: if necessary, it will be created. The recipient must have write access to the file, if it exists, and write access to its directory if it needs to be created; DELIVER grants the user no special file access privileges. V - deliver the message normally using system privileges. Under VMS V5.0 or later this action is identical to action "D" above. Under earlier versions of VMS the "From:" field of the message header is set to match the name of the original sender instead of the name of the user. This action makes use of the DELIVER foreign mail interface in incoming mode which in turn requires that the user be fully privileged. General users should use action "D" instead. E - execute the specified command. The DCL command specified by is executed. The command is executed in the environment of the recipient's own account. Any noninteractive DCL command is valid, including an indirect command file specification. Several DCL symbols can be used in the command to facilitate message processing: FROM - the message's "From:" address. TO - the message's "To:" address. SUBJECT - the message's "Subject:". CC - the message's "Cc:". QFROM - "From:" with quotes doubled. QQFROM - "From:" with quotes quadrupled. QTO - "To:" with quotes doubled. QQTO - "To:" with quotes quadrupled. QSUBJECT - "Subject:" with quotes doubled. QQSUBJECT - "Subject:" with quotes quadrupled. QCC - "Cc:" with quotes doubled. QQCC - "Cc:" with quotes quadrupled. MESSAGE_FILE - the name of the file containing the body of the message. MESSAGE_FILE is always fully qualified. MESSAGE_HEADER - the name of the file containing the headers of the message. MESSAGE_HEADER is always fully qualified. MESSAGE_DELETE - initially set to "YES", if this symbol is set to "NO" no attempt will be made to delete MESSAGE_FILE and MESSAGE_HEADER after all actions are complete. The M sets MESSAGE_DELETE to "NO" as well. The "Q" forms are useful if the symbol must be expanded inside a quoted string. The MESSAGE_DELETE flag is useful if MESSAGE_FILE and/or MESSAGE_HEADER have to be queued for further processing at a later time, or if one of the actions has already deleted them. F - forward the message. The message is forwarded to the address specified by . W - forward the message using system privileges. This action is identical to action "F" above except that the "From:" field of the message header is set to match the name of the original sender instead of the name of the user. This action makes use of the DELIVER foreign mail interface in incoming mode which in turn requires that the user be fully privileged. General users should use action "F" instead. Q - quit; take no action and abort. If this action is taken DELIVER stops scanning the MAIL.DELIVERY file at this point. No subsequent directives will apply after this one. Use this directive with care; it is very easy to lose messages when this action is employed. K - save the command file after execution. Normally the command file created on behalf of the user is deleted automatically after execution. This action, if used inhibits this automatic deletion. L - save the batch log of the DCL commands executed by DELIVER for each message processed in the file in the user's login directory. This option is useful for debugging MAIL.DELIVERY files and command scripts. If more than one L is triggered only the last one has any effect. M - save the message and header files after execution of the batch job. The message and header files are normally deleted as the last step of processing by the batch job. This action suppresses the automatic deletion; the same effect can be obtained by setting the MESSAGE_DELETE flag to "NO". J - Set the batch queue or a queue parameter used to run the command file produced by DELIVER. DELIVER uses the queue DELIVER_BATCH by default; if this queue not defined or inaccessible by the message recipient (the owner of the MAIL.DELIVERY file) the queue SYS$BATCH will be used instead. The J action provides a way to specify an alternate queue and/or a job parameter. If a single is specified it is the name of the queue. If both and are specified the former gives the name of the job parameter to set and the latter gives the value to set the parameter to. Currently the only parameters supported are P1 through P8, which set the corresponding positional job parameter to the string specified in . If the queue specified with the J action cannot be used the DELIVER_BATCH queue or SYS$BATCH queue will be used instead. For example, suppose that BOB sends JIM a message. JIM has the following (rather complex) MAIL.DELIVERY file: ! Messages with subject "Loopback" are returned to sender "JIM *" * "Loopback" T D * * "Loopback" O F """''F$ELEMENT(0,"" "",QFROM)'""" * * "Loopback" T Q ! All other messages are logged * * * A E @LOGALL.COM ! Just log messages from TERRY "TERRY *" * * T Q ! Just log archive messages from myself "JIM *" * "Archives" T Q ! Save messages from BOB in a special file "BOB *" * * T A BOB.LOG ! Then deliver anything that gets this far * * * A D JIM's LOGALL.COM contains the following commands: $ from == "From: " + from $ to == "To: " + to $ subject == "Subject: " + subject $ open/append/error=make_one x message.log $ next: $ write x "" $ write x from $ write x to $ write x subject $ write x "" $ close x $ append 'message_file' message.log $ exit $ ! $ make_one: $ create message.log $ open/append x message.log $ goto next (The same effect could be achieved now by substituting * * * A H MESSAGE.LOG for * * * A E @LOGALL.COM and would moreover have the advantage of also logging the "Cc:" field of the incoming mail.) If the subject line of BOB's message is not the string "Loopback", the message will be logged with a header in the file MESSAGE.LOG (located in JIM's SYS$LOGIN directory), appended to the file BOB.LOG without any header and delivered to JIM's NEWMAIL folder. If subject line is the string "Loopback", JIM's MAIL.DELIVERY file will bounce the message right back to BOB. As another example, if TERRY sends a message to BOB, the message is logged only in BOB's MESSAGE.LOG file; BOB never receives any notification that the message arrived. Apparently TERRY never says anything of importance to BOB. It is clear that the ability to execute an arbitrary set of DCL commands in response to a message is a very powerful tool. It must, however, be used with care, since processing is initiated whenever a message is received and operates in a completely unattended environment. Full DELIVER documentation is in DELIVER.MEM. DELIVER was written by Greg Wonderly.