MReply - mail filter, mailing list server, file server.
mreply [ -c configfile ] [ -e errfile ] [ -l logfile ]
[ -L ] [ -u username ] [ -t to-address ] [ address
]
MReply takes action based on commands given to it, typi-
cally in incoming mail messages. Possible actions include
adding or removing the mailer's address to or from a given
list, sending the mailer a plaintext or uuencoded file,
receive and decode/store a file, or forwarding the message
to another user, pipe, or mailbox.
Invocation
o If address is not specified, MReply will consider the
first few lines of the input as mail headers, and try
to extract the default reply address by parsing these.
This way, MReply can be invoked automatically upon
arrival of incoming mail messages. If your system uses
`sendmail' as the local mail delivery agent, create a
publicly readable file named `.forward' in your home
directory, containing the following line:
"|exec /path/to/mreply #your-login-name"
Be sure to include the double quotes, as well as the
pound sign in front of your login name. (Your name
should only be a comment, not an argument for MReply;
and is recommended because of a bug in `sendmail').
o Otherwise, MReply goes into a local mode, and will dis-
play a command prompt to standard output. Enter your
commands interactively at this prompt; address speci-
fies the default reply address.
-c configfile Specify a configuration file other than
the default `.mreply.rc'.
-e errfile Specify an error output file other than
the default `mreply.err'.
-l logfile Specify a log file other than the default
`.mreply.log'. Can be overridden by .LOG-
FILE in the configuration file.
-L Use long log file format. Can be overrid-
den by .LOGFILE in the configuration file.
-t to-address Override any address in the "To:" field of
when invoking MReply directly in local
mode.
Requests should be given in the body of the message, one
per line, using the following syntax:
command [argument ...] [TO|AS address]
If `TO address' or `AS address' is given, address will
override any address given in the mail header or on the
command line; but only if address is of a legal format.
This provides a means for people with broken return paths
to specify their correct address.
Built-in commands and their corresponding arguments are:
JOIN [list] | SUBSCRIBE [list]
Append address to list. If list is not
specified, append to the `[DEFAULT]' list,
if any. See also the description of the
.LIST and .LISTDIR specifications, below.
LEAVE [list] | UNSUBSCRIBE [list]
Remove address from list. If list is not
specified, remove from the `[DEFAULT]' list,
if any.
REVIEW [list]
List all subscribers of list. If list is not
specified, list subscribers of the
`[DEFAULT]' list, if any. Availibility of
this command can be prevented by declaring a
list `concealed'; see the description of the
.LIST and .LISTDIR specifications below.
WHICH Give a list of all the lists to which
address is subscribed. If several listnames
refer to the same listfile, only the first
one will be included in the response.
CHANGE old-address
Change old-address to address in all lists
known to this server.
SEND [packet [splitsize]]
Send packet via e-mail, as plain text or as
a uuencoded shell archive. If packet is not
specified, send the `[DEFAULT]' packet, if
any. The optional second argument splitsize
specifies the maximum size (in bytes or
kilobytes) per mail message. See also the
ACCESS [code]
Provide a code for a subsequent file submis-
sion. See also the description of the
.RECEIVEDIR specification, below.
TEXT filename
Save the rest of the message as plaintext to
filename in the directory specified with the
.RECEIVEDIR specification and/or the ACCESS
command. See below for details.
BEGIN mode filename
Uudecode the rest of the message to filename
in the directory specified with the
.RECEIVEDIR specification and/or the ACCESS
command. See below for details.
The mode should be an octal number describ-
ing the permissions of the stored file.
HELP [topic]
Return some text specified in the configura-
tion file to address. Intended for basic
help on syntax, available commands, lists,
packets and/or services, whichever applica-
ble.
SERVERINFO
Return some information about the site con-
figuration and the current version of MReply
to address.
Examples
The following are some examples of legal syntax for com-
mands given to MReply:
JOIN announcement AS alice@wonderland.com (Alice)
leave notgnu-list
SEND DNOT 60 TO foo@bar.com (Foo Bar)
send info
SERVERINFO
change foo@obsolete.com to foo@bar.com (Foo Bar)
The following syntax is available in the configuration
file, by default `.mreply.rc' in your home directory.
Keywords
These are looked up at various points during processing of
the request, and determine the behaviour of this particu-
lar server. Each keyword specification should occur on a
chosen.
.GLOBALINIT
.COMMANDINIT
When available, .GLOBALINIT is parsed once
before any commands in the incoming mail is
processed, whereas .COMMANDINIT is parsed
prior to processing of each command in the
mail. Parsing is similar to that of .MES-
SAGE, .COMMAND, and .SIGNATURE specifica-
tions (described below), but any included
text is ignored. Terminated by an .END
statement.
.SERVICEADDRESS address
.OWNERADDRESS address
Declaration of the address for this service,
and its owner. These are used in various
contexts, such as in the "X-Loop:" mail
header and ServerInfo responses. If not
present, MReply will assume "username (Your
Name)" as both server and owner address,
(and thus let `sendmail' take care of
appending the host name when this address
occurs in outgoing mail headers).
.FORWARD [-options] destination
.FORWARDALL [-options] destination
.LOOPEDFORWARD [-options] destination
.NOFORWARD
Forward non-request mails, all mails, looped
mails, and no mail, respectively. For these
specifications, destination should be pre-
ceeded either by one of >, !, |, @, or #, or
by one of their equivalents described below,
the following way:
.forward > mbox1 [mbox2 ...]
Forward the mail to the first
successfully opened file of
the ones specified. If the
mailbox name ends with a "/",
it is assumed to be a direc-
tory, and your login name is
appended. For instance,
"/usr/spool/mail/,
/usr/mail/" is expanded to
"/usr/spool/mail/your-name,
/usr/mail/your-name".
.forward ! user@host.domain
Forward the mail to another
Pipe the mail to a command
via '/bin/sh'.
.forward @ commandline
Flush the mail, and instead
execute a command via
'/bin/sh'. Any output from
this command is returned to
the mailer.
.forward # label
Instead of forwarding the
mail directly, look for
.label label in the configu-
ration file and parse from
there.
The following options are also available:
-noheader
Don't include the mail header
in the forwarded message.
-nobody
Don't include the body in the
forwarded message.
-nosig Don't include any .signature
in the forwarded message.
Default when forwarding to a
mailbox, or when forwarding
via .packet and .list decla-
rations, described below.
-sig Do include any available
.signature specification in
the forwarded message.
Default when forwarding text
mails to another user or a
command pipe.
-file mbox1 [mbox2 ...]
Same as '>'; must be the last
option.
-addr user@host.domain
Same as '!'; must be the last
option.
-pipe commandline
Same as '|'; must be the last
option.
Same as '@'; must be the last
option.
-goto label
Same as '#'; must be the last
option.
If neither >, !, |, @, #, -file, -addr,
-pipe, -exec, or -goto is specified, the
destination is assumed to be a mailbox
(file).
The following processing takes place:
o If no configuration file is found,
the mail is forwarded to -file
/usr/spool/mail/, /usr/mail/, .mail-
box/inbox, mbox
o Otherwise, if the mail has been here
before (i.e. contains an appropriate
X-loop: header), it is forwarded via
the .LOOPEDFORWARD specification,
your regular mailbox by default.
o Otherwise, if a .FORWARDALL specifi-
cation is found, all mail is for-
warded according to this.
o Otherwise, if a .NOFORWARD specifi-
cation is found, all mail (request
or not) is processed, and responded
to.
o Otherwise, only request mail is pro-
cessed and responded to, while regu-
lar mail is forwarded via .FORWARD;
your mailbox by default.
.ALIAS alias-name command
Makes alias-name an alias for command, which
is either a built-in command or one defined
with the .COMMAND keyword, described below.
Has higher precedence than any of these.
.PROCESS command arguments [TO|AS reply-address]
Enqueue a command line to be processed after
the current one, as if it was given sepa-
rately in the incoming mail. Only available
during parsing of .GLOBALINIT, .COMMANDINIT,
.MESSAGE, .COMMAND, and .SIGNATURE defini-
tions.
in the current response, all of these will
be enqueued before any of them is handled.
Thus, .PROCESS statements occuring in the
current response text will be handled before
any that occur in the responses to the com-
mands being invoked. If you don't know what
this means, no worries.
.LIST listname listfile [modifier...]
.LIST listname -options destination
.LIST listname [-options] > file1 [, file2 ...]
.LIST listname [-options] ! user@host.domain
.LIST listname [-options] | commandline
.LIST listname [-options] @ commandline
.LIST listname [-options] # label
Specification of subscriber lists. In the
first case, commands like `SUBSCRIBE list-
name' or `REVIEW listname' will affect
listfile, whose name is absolute (full path)
or relative to your home directory.
A special case occurs if the first character
of the second argument is one of '-', '>',
'!', '|', '@', or '#'. The request will
then be forwarded according to the .FORWARD
description above.
If listname is `[DEFAULT]', this line
applies to commands without any argument,
for instance a simple SUBSCRIBE or UNSUB-
SCRIBE AS user@host.domain.
The following modifiers are available:
AUTOMATIC Automatically add the
mailer's address to this
list, even if no explicit
JOIN or SUBSCRIBE command
is given. Not valid if
the mail is determined to
be a `regular' mail.
MANUAL Only add mailers who give
explicit JOIN / SUBSCRIBE
commands. (Default).
CONCEALED Do not allow REVIEW com-
mands on this list.
REVEALED Allow REVIEW on this list.
(Default).
mailing list unless they ask for it
explitictly, particularly if the list car-
ries a lot of traffic.
.LISTDIR directory [modifier...]
.LISTDIR -options destination
.LISTDIR [-options] > file1 [, file2 ...]
.LISTDIR [-options] ! user@host.domain
.LISTDIR [-options] | commandline
.LISTDIR [-options] @ commandline
.LISTDIR [-options] # label
In the first case, this is a directory where
to look for a filename matching the argument
of e.g. a JOIN or LEAVE command, if no
matching .LIST specification is found. Note
that such lookup will be case sensitive, so
the case of the argument has to match the
case of the desired filename. Several of
these lines will cause MReply to look
through all the specified directories, in
the order of appearance.
If the first character of the first argument
is one of '-', '>', '!', '|', '@', or '#',
the request is forwarded according to the
.FORWARD description above, and subsequent
.LISTDIR specifications will have no effect.
.PACKET packetname filename [encoding]
.PACKET packetname -options destination
.PACKET packetname [-options] > file1 [, file2 ...]
.PACKET packetname [-options] ! user@host.domain
.PACKET packetname [-options] | commandline
.PACKET packetname [-options] @ commandline
.PACKET packetname [-options] # label
Specification of available packets. In the
first case, when a SEND packetname command
is given, the associated filename (absolute
or relative to your home directory) is
returned to address; whereas if the first
character of the second argument is one of
'-', '>', '!', '|', '@', or '#', the request
will be forwarded according to the .FORWARD
description above.
If packetname is `[DEFAULT]', this line
applies to SEND commands without any argu-
ments.
The following encodings are available:
PLAINTEXT Send the file `as is',
shell archive.
AUTODETECT
Let MReply determine
whether to encode the
file. (Default).
.PACKETDIR directory [encoding]
.PACKETDIR -options destination
.PACKETDIR [-options] > file1 [, file2 ...]
.PACKETDIR [-options] ! user@host.domain
.PACKETDIR [-options] | commandline
.PACKETDIR [-options] @ commandline
.PACKETDIR [-options] # label
In the first case, this is a directory where
to look for a filename matching the argument
of a `SEND argument' command, if no match-
ing .PACKET specification is found. Note
that such lookup will be case sensitive, so
the case of the argument has to match the
case of the desired filename. Several of
these lines will cause MReply to look
through all the specified directories, in
the order of appearance.
If the first character of the first argument
is one of '-', '>', '!', '|', '@', or '#',
the request is forwarded according to the
.FORWARD description above, and subsequent
.PACKETDIR specifications will have no
effect.
.RECEIVEDIR directory [access-code]
Directory in which to place files submitted
to this server. If access-code is specified,
the mailer has to gain access via an
`ACCESS access-code' command before being
allowed to submit files to this directory.
Several directories with different access-
codes can be specified. The first valid
entry is chosen, therefore a specification
without access-code should appear as the
last one.
File names supplied by the mailer are
stripped to the base, so that the files will
not appear in any other directory than the
one (s)he has gained access to.
.SETENV variable value
Set environment variable variable to value.
.UNSETENV variable
Clear environment variable variable.
.LOGFILE filename [logtype]
Use filename to log the request, rather than
the default `.mreply.log' or any file speci-
fied with the -l logfile option on the com-
mand line.
If logtype is specified, it overrides the -L
option or the default `short' logging.
Valid logtypes are:
SHORT Use a one-line log format.
LONG Use a multi-line format
with more information;
useful for debugging dur-
ing configuration of your
system.
.PURGEHEADER Header-Field:
Delete the mail header specified before for-
warding the mail.
.INSERTHEADER Header-Field: Text
Add a new header before forwarding the mail,
if not already existing. Executed after
.PURGEHEADER, hence uniqueness can be guar-
anteed by providing both specifications on
the same Header-Field.
.ADDHEADER Header-Field: Text
Add a new header before forwarding the mail,
without checking to see if it already
exists.
.HEADER Header-Field: Text
Specify a header for reply mail, i.e.
responses to commands. If no `To:' and
`From:' headers are specified, they will be
automatically generated.
.SIGNATURE [command [argument]]
Specify a signature to append to all
responses, as well as mails forwarded to
anything else than a mailbox. If command
and possibly argument is specified, this
signature is used only in response to match-
ing command lines.
Specification of various responses returned
to address upon completion of a request.
Also valid inside other .MESSAGE, .COMMAND,
.LABEL, or .SIGNATURE declarations. Every
line that is not initialized with a `.' is
included in the response to address.
The following message-labels should be spec-
ified:
If .LIST or .LISTDIR specifications
exist:
Added, AlreadyAdded, Removed,
NotInList, Review, Con-
cealedList, IllegalList,
Which, NotInAnyList, Changed,
NoChange.
If .PACKET or .PACKETDIR
specifications exist:
SendPlain, SendEncoded, Ille-
galPacket.
If .RECEIVEDIR specifications exist:
ReceivePlain, ReceiveEncoded,
DecodeError, NoAccess.
Always:
Help, Unavailable, SyntaxEr-
ror, EmptyMail.
Optional:
AutoAdded, Forwarded, Looped,
Resent, Header, Signature,
ServerError.
See also the .END statement, below.
.IGNORE message [argument]
If no matching .MESSAGE message statement
can be found, this prevents an error message
from being returned to address. Function-
ally equivalent to .MESSAGE message, fol-
lowed immediately by .END.
.COMMAND command [argument]
Start of a user-defined command. Also valid
inside other .MESSAGE, .COMMAND, .LABEL, or
.MESSAGE declarations. Every line that is
not initialized with a `.' is included in
the response to address. See also the .END
statement, below.
The end of a .MESSAGE, .COMMAND, or .SIGNA-
TURE specification, or a .LABEL when called
via .GOSUB. Neither of these can be nested,
so one .END statement may complete several
specifications. In the case of .LABEL, sub-
sequently return to the line after the call-
ing .GOSUB statement, if any.
.END is automatically assumed when encoun-
tering an .ELIF, .ELSE or .ENDIF statement
matching an .IF statement prior to the
beginning of the .MESSAGE, .COMMAND, .LABEL,
or .SIGNATURE, or upon encountering end-of-
file.
.INPUT [filename]
Select input source for the .READ and .EXEC
commands. If filename is not specified, any
previous input files are closed and standard
input is selected. Otherwise, filename is
opened and rewinded.
.READ [variable]
Read a line, by default from the incoming
mail (can be overridden by an .INPUT speci-
fication), and store in variable, if speci-
fied. The RETURNSTATUS variable is set to
`0', or '-1' if end-of-file is encountered.
.INSERT filename
Include the text from filename in the
response, without any kind of variable or
function subsitutions (Described below).
Only valid during parsing of .MESSAGE, .COM-
MAND, or .SIGNATURE specifications.
.INCLUDE filename
Include the text from filename in the
response, with substitutions as described
below. Only valid during parsing of .MES-
SAGE, .COMMAND, or .SIGNATURE specifica-
tions.
.EXEC commandline
Execute command via `/bin/sh'. Input is by
default taken from the mail message, start-
ing at the current point (can be overridden
with an .INPUT specification); standard out-
put is included in the reply to the user;
and output sent to standard error is stored
in the variable $ERRORMESSAGE. The return
status from the program is stored in
exhausted, and no .FLUSH command is given,
parsing of the remainder of the message will
continue.
Only valid during parsing of .MESSAGE, .COM-
MAND, or .SIGNATURE specifications.
.FLUSH
Eat the rest of the mail message. Useful in
certain cases after an .EXEC command. Only
valid during parsing of .MESSAGE, .COMMAND,
or .SIGNATURE specifications.
.ERROR message
Generate a message in the error file.
.LABEL label
Label for .GOTO and .GOSUB. Valid at any
point in the configuration file, even if
inside unsuccessful .IF, .ELIF or .ELSE
statements. See also the .END statement,
below.
.GOTO label
.GOSUB label
Jump to .LABEL label, and continue parsing
from there. In the case of .GOSUB, return
to the current point upon .END, .ENDIF, or
end-of-file, as described for the .END
statement, above.
.IF [NOT] expression
.AND [NOT] expression
.OR [NOT] expression
.ELIF [NOT] expression
.ELSE
.ENDIF
Conditional parsing of the enclosed sec-
tions. Conditions are evaluated from left
to right (actually top down) without any
different priority levels. (However, nested
conditions are available).
Syntax for expression:
TO address
True if address exists in any
of the To:, Cc:, Apparently-
To:, or Resent-To: headers.
If the -t option is used when
invoking MReply, true if
address matches the to-
FROM address
True if address exists in any
of the Return-Path:, From,
Resent-From:, Sender:, X-
From:, From: or Reply-To:
headers. If MReply is
invoked in local mode, true
if address matches the reply
address given on the command
line.
FILE name CONTAINS string
FILE name EQUALS string
FILE name EXISTS
HEADER Field: CONTAINS string
HEADER Field: EQUALS string
HEADER Field: EXISTS
string CONTAINS string
string EQUALS string
string EXISTS
num1 = num2
num1 < num2
num1 > num2
num1 <= num2
num1 >= num2
Each condition has to start on a separate
line, and the number of .ENDIF statements
has to match the number of .IF's.
Substitutions
Various substitutions are available in the configuration
file, including environment variables, shell command out-
puts, and some built-in commands. The following is a
description of syntax for these.
\c
If `\' is the last non-white character on
the line, include the next line in the dec-
laration.
Otherwise, escape character c according to
the following:
o If c is one of b, t, n, v, f, or r,
insert a backspace, horizontal tab,
newline, vertical tab, formfeed, or
return character, respetively.
it. For instance, `\\' gives `\',
and `\)' gives `)'.
~/
~user/
Substitute your own home directory, and the
home directory of user, respectively.
:variable:
$variable
${variable}
Substitute environment variable variable.
The following variables are automatically
specified by MReply:
USER Username of the process
owner, initialized at
startup.
HOME The process owner's home
directory, initialized at
startup.
PATH The search path for sub-
command executions. If not
present before invoking MRe-
ply, initialized to some
basic search-path at that
time.
ACCESS The access-code supplied via
the ACCESS command; initial-
ized to `[DEFAULT]' at
startup.
SERVICEADDRESS
The address of this service,
as read from the .SERVICEAD-
DRESS specification in the
configuration file at
startup.
OWNERADDRESS
The address of the owner, as
read from the .OWNERADDRESS
specification in the configu-
ration file at startup.
HEADERADDRESS
The default reply address, as
specified on the shell com-
the form:
user@host.domain (Real
Name)
FULLADDRESS
The reply address for this
command, as specified with
the TO or AS keywords; by
default equal to HEADERAD-
DRESS.
ADDRESS
The user@host.domain part of
FULLADDRESS.
USERNAME
The user part of FULLADDRESS.
FULLNAME
The Real Name part of FULLAD-
DRESS, or if not given, the
user part of it.
NAME Generally the first word of
FULLNAME.
MAILTYPE
One of PLAIN, COMMAND, or
FILE, depending on the type
of the mail being processed.
COMMANDLINE
The command line currently
being processed.
COMMAND
The first word of COMMAND-
LINE.
ARGUMENTS
All arguments for the current
command. A substring of COM-
MANDLINE starting at the sec-
ond word, and ending before
TO, AS, or end-of-line.
ARGUMENT
The first argument for the
current command. Generally
equal to the second word, but
exceptions may occur if TO|AS
address is specificed.
The second argument for the
current command. Generally
equal to the third word.
PATHNAME
The full path of the file
associated with a given argu-
ment. Initialized after suc-
cessfully parsing a .LIST,
.LISTDIR, .PACKET, PACKETDIR,
or .RECEIVEDIR specification,
before returning a response
to the reply address.
FILENAME
The base of PATHNAME
PARTS The number of e-mails compos-
ing a file sent in response
to the SEND command. Avail-
able for the SendPlain or
SendEncoded responses.
MESSAGE
The response message that is
currently being sent, i.e.
`Added', `AlreadyAdded',
`Removed', etc.
ERRORMESSAGE
Initialized upon ServerError
responses, or whenever an
invoked shell command writes
to standard error.
RETURNSTATUS
Initialized upon completion
of an invoked shell command;
and contains its return
value.
Environment variables are inherited by
invoked sub-shell commands, and are set or
cleared with the .SETENV or .UNSETENV com-
mands.
$function(arg1, arg2...))
Substitute with output from a built-in func-
tion. Wherever a numeric argument is
required, any non-numeric syntax will pro-
duce an error message in the error file.
Functions can be nested, so an argument can
$WORD(string, wordNo[, noOfWords]))
Word number wordNo of string.
The first word is number 1,
however if wordNo is 0 the
word is only copied if there
are no leading spaces in
string. If noOfWords is
given, it specifies the num-
ber of words to copy; a value
of 0 indicates to copy the
remainder of the string.
$CHAR(string, charNo[, noOfChars]))
Character number charNo of
string. The first character
is number 1. If noOfChars is
given, it specifies the num-
ber of characters to copy; a
value of 0 indicates to copy
the remainder of the string.
$TRIM(string))
Remove leading and trailing
whitespaces and newlines from
string.
$REPL(string, charNo, noOfChars,
newString))
Replace noOfChars characters,
starting at position charNo
of string, with newString.
$POS(string, substring))
Position of substring within
string. The first position
is 1; if substring is not
found, return `0'.
$LEN(string))
The length of string.
$SPACE(n)
A string consisting of n
whitespaces.
$ADD(n1, n2...))
The sum of the numerical
arguments n0, n1... The max-
imum number of arguments is
10.
All arguments starting with
n2 subtracted from n1. The
maximum number of arguments
is 10.
$UPCASE(string))
Convert string to uppercase.
$DOWNCASE(string))
Convert string to lowercase.
$HEADER(Field:))
The Field: header of the
input mail.
$LISTFILE(listname))
The name of the listfile that
corresponds to listname.
$PACKETFILE(packetname)
The filename that corresponds
to packetname.
`command arguments`
$(command arguments)
Substitute with the output from command,
executed via /bin/sh. Return status is
stored in the variable RETURNSTATUS, and any
output written to standard error is stored
in ERRORMESSAGE.
$HOME/.mreply.rc Default configuration file.
$HOME/.mreply.log Default log file.
$HOME/mreply.err Default error file.
/etc/passwd Used to obtain the USER and HOME vari-
ables.
/usr/spool/mail/$USER, /usr/mail/$USER
Default mailbox.
/usr/lib/sendmail Used to send or forward mail.
/bin/sh Used to interpret sub-command lines.
sh(1), sendmail(8)
During processing of a mail message, or even a single com-
mand, the configuration is (partly) parsed several times.
Therefore, one should not count on evironment variables
being un-initialized if they are assigned a value further
down in the file. To secure against this, give a
.UNSETENV variable statement prior to referencing the
variable.
There are no known misbehaviors in this version of MReply.
If you discover any, please send a mail to the address
below.
To receive the newest version, send an e-mail with body
SEND MREPLY to <mreply-request@netcom.com>, or retreive it
via anonymous FTP to ftp.netcom.com in /pub/tor/mreply.
Two associated mailing lists are available:
MReply-Updates
An announcement list for future updates.
MReply-List
An interactive MReply discussion list,
devoted to setup, configuration, questions,
comments etc.
To subscribe to either or both of these lists... You fig-
ure out what to do! The address is <mreply-
request@netcom.com>.
Tor Slettnes <tor@netcom.com>