Mailtraq's Remote Console is used to administer the Mailtraq server using only a TCP/IP connection. This is done using the Remote API which is able to control almost every element of Mailtraq's configuration and some of its functionality too. As of build 2962 a fully functioning scripting interface is available which allows administrators to control functions not exposed in the Remote Console and to perform more complex tasks. You can access this feature through the Execute Script command in the Tools menu of the Remote Console.

ScriptExecute.png (66.42 KiB) Viewed 6913 times

When you open the Script Execute window a small demonstration script is created. There are two global objects available, Server and Output. The Server object represents the Mailtraq Server while the Output object is used to communicate with the User. This scripting environment includes documentation which appears when you enter "." or "(". For example, if you type "Server." then a list of all members of "Server" will appear in a drop-down box. If you type "Output.Confirm(" then the list of parameters will be displayed. This is a useful way to explore the available functionality.

Here is a sample script which looks for orphaned mailboxes, calendars and address books. This problem happened to some users because of a fault in the Remote Console a few builds back. The script will do some analysis first and won't actually make changes unless you confirm first.

// checkowners.js// Mailslot, Address book and Calendar ownership verification script// // This script looks at each address book and calendar to see// if there is a user with the same name who is not the owner.// If it finds a match, the object can be assigned to the correct// owner.//// If you want some of the changes and not others, then take the// output (produced in the Output tab when the script is executed)// and remove the uncommented lines that you don't want, then// execute the rest.

Here is a sample script that corrects the Primary Mailbox assignment for users in cases where the primary mailbox has been renamed and the user cannot log in via WebMail any more. The script simply searches for users with invalid primary mailbox references and resets them to the default (which is a mailbox that matches the user name).

// you don't have to call Save() as changes are automatically // applied when an object goes out of scope, but this ensures // the change happens at the right time even if the script is // interrupted later user.Save(); } else { Output.WriteLine("User " + user.Name + " -> " + pm + " -- OK"); } } }}