The first is quite simple. Mail sent to either of
that has a Subject of the formST-comment@math.uwaterloo.ca
ST-comment@cs.uwaterloo.ca
[UW-MFCF #ITEM_NUMBER] the real subjectbecomes a comment in ST #ITEM_NUMBER, recorded with just the real subject. The subject prefix can be omitted by mailing to either of
ST-comment+ITEM_NUMBER@math.uwaterloo.caIt moves each message attachment into
ST-comment+ITEM_NUMBER@cs.uwaterloo.ca
https://www.cs.uwaterloo.ca/cscf/internal/edocs/rtattach/ITEM_NUMBER/attachment_namereplacing it in the message with a URL, after the line "Attachments:" appended to the end of the message.
The second gateway does more. Mail sent to
rt-em-gw+ITEM_NUMBER@cs.uwaterloo.cais preprocessed before being resent to the simple gateway above. It attempts to remove included mail messages, by replacing lines that begin with > with the text > [snip...]. This has the advantage of avoiding those conversational mail messages that just keep growing. It has the disadvantage that it can lose included mail messages that were previously recorded in the item.
Details of this second gateway follow.
ST-comment@cs
with [UW-MFCF #STNUM]
as the subject (where STNUM
is the number of the ST item) as comments to that item.
In addition, any attachments in that email are automatically extracted, saved as discrete files in CS web space ("eDocs") and then replaced with a link to those documents in the resulting ST entry. This is particularly convenient for forwarding Purchase Orders, quotes and other documents that may be relevant to a given request.
rt-em-gw+[STNUM]@cs.uwaterloo.ca
, where [STNUM]
is the number of the ST item. For example, to add content to ST #58225, send a message to rt-em-gw+58225@cs.uwaterloo.ca
. This address can appear in either the To
or CC
fields of the e-mail header, but not in the BCC
field.
rt-em-gw
User rt-em-gw
. This allows us to have an address to send e-mails to. The gateway implementation resides entirely under this user's home directory, which is /u2/rt-em-gw
in the CS general computing environment. This directory contains the following files and sub-directories of interest:
~/.procmailrc
Directs incoming e-mails to the gateway script
~/emailgw/
The main implementation directory
~/emailgw/bin/emailgw.pl
The gateway implementation, as a Perl script
~/emailgw/lib/
Perl modules required by the gateway script, but unavailable in the default CS Perl installation
~/emailgw/log
Log file used by the gateway script
~/emailgw/plugins/
Plug-in scripts that can be used to process a message before it is forwarded to the ST system
rt-em-gw
in either the To
or CC
fields of the header to further processing by the gateway script. This is done by the following .procmailrc
file in the rt-em-gw
home directory:
MAILDIR=$HOME/mail :0: * ^(To|Cc).*rt-em-gw\+ | $HOME/emailgw/bin/emailgw.pl >> $HOME/emailgw/log
To
and CC
fields are searched for an address of the expected form (i.e., rt-em-gw+[STNUM]@cs.uwaterloo.ca
)
ST-comment@math
as the recipient and [UW-MFCF #STNUM]
as the subject
~/emailgw/plugins/
directory (see below)
rt-em-gw
address from the CC
field, so that it doesn't show up in the result (this is just for aesthetic reasons)
Subject
, To
, Date
, etc.), so that they show up in the ST comments (the built-in ST fields show the information of the message constructed by the gateway)
$body$
, which contains the message's body text. A plug-in is expected to modify this variable in-place (i.e., no value needs to be returned from the script). As an example, consider the following plug-in to remove the original text from a response message:
# Get an array of lines. @lines = split('\n', $body); # Reset the body variable. $body = ""; # Add back to the body all the lines that do not start with the greater-than sign. foreach (@lines) { if (!($_ =~ m/^\>/)) { $body .= "$_\n"; } }Plug-ins are executed according to the
~/emailgw/plugins/index
file. This file contains a simple list of plug-ins that determines which plug-ins to execute and in what order. The gateway script will interpret every non-commented line (i.e., a line that does not begin with a hash sign) as a file name to open and run.
MIME::Entity
MIME::Parser
Mail::Send
~/emailgw/lib/
. The gateway script uses the use lib
directive to add this directory to the list of directories Perl searches for modules.