KB09092301 Scripting exampleThis worksheet is an example of how to use scripting in Mailtraq. The example shows how to change the domain name generated by, in this case, a mailing-list. Outline The procedure is in two parts: first - write the script; second - define the trigger. The scripting controls are accessed from the Console | Options | Scripts and Templates Create the script Open the Scripts and Templates dialog, select the Scripts-tab and click the [New] button. Enter your script in the window that opens - for example: // New Script // Lines beginning with double forward slashes are comments <@LANGUAGE=Javascript@> <% if (Request.GetHeader("From").match("test@domain.com")) Request.SetHeader("From", "The Test Account <test@change.com>"); %> Then 'Save' - the script will have a name - 'change' in this example. Set the Trigger - Part 1 Select the Automated Scripting-tab Select the Script you want to trigger - 'change', in this example. Set the Script Trigger Set the Trigger - Part 2 Select the Message Trigger-tab Set to, say, All Messages Set when the script will be applied. For example: Outbound Mail Delivery - the script will only be applied to messages leaving the server (not local). Mail Routing - the script will be applied to all messages. Set the 'Script will modify the message' control. The script activation is set by the 'Enable this Script' control. Testing When you are testing your script make sure that you are testing under the correct conditions - for example, if your script is applied only on Outbound Mail Delivery you will need to check the receipt of the message on a remote mail server you have access to - say your personal email. |