Copy messages to automation

This forum is for discussing Mailtraq's Scripting features. Get help with Mailtraq scripts, templates and external ActiveX scripting.

Copy messages to automation

Postby dan » Mon Mar 06th, 2006 12:56pm

Is there a way of automating the "send a copy of all messages to" function?

I would like the users to be able to tell the server who they wish to redirect their mail to.

So user.a@domain.com sends

to:server@domain.com
subject:forward
----Message Body -------
user.b@domain.com
[keep|delete]
[respond]
[acknowldege]


This would then set the "checkbox" of "send a copy of all messages to", then based on the square bracket ([ ]) options would also set the other options in the mailbox properties dialog - mail tab

I thought about using scripting, but I cannot seem to find the right functions, am I barking up the wrong tree??

Thanks in advance

Dannie
dan
 

Re: Copy messages to automation

Postby Martin Clayton » Wed Mar 08th, 2006 7:32am

Hi Dannie,
dan wrote:Is there a way of automating the "send a copy of all messages to" function?

I would like the users to be able to tell the server who they wish to redirect their mail to.

This functionality is available under the old WebAdmin service (<http://mtq/$>) but ...

So user.a@domain.com sends

to:server@domain.com
subject:forward
----Message Body -------
user.b@domain.com
[keep|delete]
[respond]
[acknowldege]

mailslot.AutoresponderActive & mailslot.AutoresponderText can do some of the work. I'd guess ACK is accessible from mailslot.HasProperty() or AddProperty() ... so that just leaves the 'Copy message To' and optional 'Keep/Delete'. There are a couple of undocumented mailslot properies in webmail's optionsmail.asp but not quite what you're after.

If that's the case, it can be done but it's a bit long-winded -- the script would have to (i) spot control messages and maintain user settings (ii) re-set RCPTs as specified. If it's triggered on inbound mail, resolving RCPTs to mailslots might be tricky and there's also the danger that the two 'Copy-To' control points go out of synch.

Maybe someone can think of an easier way but I suspect it would be worth waiting for the mailslot properties to come on line. At that point, I'd like to see the functionality in 'standard' webmail.

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK

Re: Copy messages to automation

Postby dannieb » Wed Sep 19th, 2007 7:34am

Okay, I am still looking into this feature, [nearly] a year later. I am curious to know how other people handle users "holidays." As far as my knowledge goes, there are two ways to achieve (currently) this.

1. Open Mailtraq, find user, find mailbox, right click mouse, select properties, click checkbox "Send a copy of all incoming messages to", find the designated user using the combo box click "Okay" button.

2. Use the "Aliases" file, then restart Mailtraq.

Every time a member of staff goes on holiday, their mail has to be copied to a nominated person, just in case its something important, like an order, or a support request. Once they are back, the copy mail directive must be cancelled. I have to admit, When I (the admin) am away, there is another person who takes on responsibility for this. Often is the case where they have made copy rules, and I know nothing about it until the user phones up asking if I can cancel this process.

I appreciate the process is not exactly over intensive, but I would prefer if the user could control the copy by sending the server a message. I think its logical, maybe I am too lazy?
dannieb
 
Posts: 4
Joined: Mon Mar 06th, 2006 12:09pm
Location: London

Re: Copy messages to automation

Postby jimhill » Wed Sep 19th, 2007 4:17pm

dannieb wrote:I am curious to know how other people handle users "holidays." [...] Every time a member of staff goes on holiday, their mail has to be copied to a nominated person, just in case its something important, like an order, or a support request. Once they are back, the copy mail directive must be cancelled. [...]I appreciate the process is not exactly over intensive, but I would prefer if the user could control the copy by sending the server a message.
Seems simple enough to me. Set up an autoresponder which is filtered to accept mail only from you and your deputies. Modify the autoresponder template to attach Mailtraq's aliases file in response to the receipt of a blank message or to overwrite the current aliases file in response to the receipt of a message with an aliases file attached. There's no need to restart Mailtraq after changes to the aliases file, btw.

I can code that for you, if required.
jimhill
Expert User
 
Posts: 337
Joined: Sun Dec 19th, 2004 9:59pm
Location: UK

Re: Copy messages to automation

Postby Martin Clayton » Fri Sep 21st, 2007 12:26pm

I prefer to avoid the aliases file (due to problems resolving multiple recipients) so I'd veer towards changing the mailslots' properties. Forwarding is accessible via the mailslot.ForwardTo("[comma separated list of addresses]") and ForwardActive([1|0]) methods. However, I think the best way of getting at your [keep/delete] and [acknowledge] options is with direct writes to \configuration\mailslots\{mailslot}.cfg

Code: Select all
[Main]
ExpandAliases=1    // enable Forwarding [written by ForwardActive()]
StoreMail=1        // keep or delete messages on forwarding
Properties=16      // includes Acknowledge Delivery Receipt Requests

[addresses]        // [written by .ForwardTo()]
=address1@example.net
=address2
=address3@example.com

Enabling/disabling the [acknowledge] option seems to require addition/subtraction of 536870912 but this needs testing.

If you want to do the javascript thing, I can give you a routine to read the mailslot configuration file (I've got one ...somewhere [it needed Toolkit.HashMD5() to resolve escaped mailslot names]) and it wouldn't be difficult to parse an input message for your [control flags].

Don't let this put you off Jim's route and offer - you'd be in very safe hands.

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK

Re: Copy messages to automation

Postby jimhill » Fri Sep 21st, 2007 3:33pm

Martin Clayton wrote:I prefer to avoid the aliases file (due to problems resolving multiple recipients)
That wouldn't be a problem in this application but I do realise that it's an issue in more complex setups. A thought just occurred on the latter, have you tried using multiple entries to resolve all the recipients correctly? That is, Instead of ...

# test one
usera: usera, userb, userc

... you could try ...

# test two
usera: userb
userb: userc

Martin Clayton wrote: so I'd veer towards changing the mailslots' properties.[snip details]
Some excellent ideas there. I'd forgotten that it's now possible to edit Mailtraq's cfg files directly (but with care!).

If I needed to do this on my setup, I'd use perl to add "RCPT: user@host" directly to the routing entries of the incoming message file in Mailtraq's messagefilter - so much simpler.

Martin Clayton wrote:Don't let this put you off Jim's route and offer - you'd be in very safe hands.
Not so safe, I'm afraid. I got back into work-mode this week only to find that Mailtraq's upgrade protection had expired without me noticing (yet again). Bob to the rescue once more, hopefully.
jimhill
Expert User
 
Posts: 337
Joined: Sun Dec 19th, 2004 9:59pm
Location: UK

Re: Copy messages to automation

Postby Martin Clayton » Sat Sep 22nd, 2007 5:03am

[aliases file]
jimhill wrote:have you tried using multiple entries to resolve all the recipients correctly? That is, Instead of ...

# test one
usera: usera, userb, userc

... you could try ...

# test two
usera: userb
userb: userc

I don't think so - thanks - but I get the impression that the problem is at the other end of equation; recipients 2+ aren't passed to the resolver. In effect, more than one entry in the file is potentially problematic.

Jim Hill wrote:If I needed to do this on my setup, I'd use perl to add "RCPT: user@host" directly to the routing entries of the incoming message file in Mailtraq's messagefilter - so much simpler.

I've recently put together a tnef-decoder borrowing heavily from sections of your shunt script. It seems to be working fine under vista and win2k but as a first attempt to do anything useful there must be some coding howlers (not the bits plucked from your routine!) While we're here, I'd appreciate your advice on the best way to invoke the monitoring script at boot-up when Mailtraq is running as a service. Do you use a scheduled task to run a dos-session? I've seen references to GUIPerl and activestate's wperl.exe (to hide the console) but how do you get the show on the road?

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK

Re: Copy messages to automation

Postby jimhill » Mon Sep 24th, 2007 7:49pm

Martin Clayton wrote:[aliases file]
[...] I get the impression that the problem is at the other end of equation; recipients 2+ aren't passed to the resolver. In effect, more than one entry in the file is potentially problematic.
Have you got an example of (part of) the problem handy? If so, perhaps you could post it to a new thread.

Martin Clayton wrote:I've recently put together a tnef-decoder
Using Convert::TNEF, hopefully.

Martin Clayton wrote:I'd appreciate your advice on the best way to invoke the monitoring script at boot-up when Mailtraq is running as a service.
You have a number of options ...

1. Create a shortcut -- c:\perl\perl.exe x:\yourpath\yourscript.pl -- in the Start folder of the Start menu.
2. Batchify your perl script (from a dos prompt -- pl2bat x:\yourpath\yourscript.pl -- to output yourscript.bat) and use it as (1) or create a runonce entry for it in the registry.
3. Create a service to run your script -- this is a little tricky and you need support programs (freely downloadable) but it only needs to be done once.
4. Create an .exe from your script -- I have the (non-freeware) tools to do that for you -- and use it in any of the above.

Martin Clayton wrote:Do you use a scheduled task to run a dos-session?
No, but that's also a viable technique.

A better alternative to all the above, imo, is to create a startup perl script to initiate all the programs and services required on your machine. The big advantage of doing it this way is that you can control the order in which programs and services load into memory -- for example, you can easily disable the machine's network card until its (software) firewall has loaded. The downside is that inconsiderate programs, like Mailtraq's update utility, stomp all over your custom services settings so you need to run them via a perl script as well (see my website) to correct their false assumptions and to remove their unwanted and misplaced entries in the Start menu.

Martin Clayton wrote:I've seen references to GUIPerl and activestate's wperl.exe (to hide the console) but how do you get the show on the road?
Forget guiperl, it's used only to provide a user interface to perl scripts. The programs perl.exe and wperl.exe are interchangeable so all the above options are available with both. If your script outputs to stdout, you'll need to use perl.exe because it provides a visible console which can start up, and run, minimised. If your script outputs to a separate log file or to windows' event log, you can invoke it using wperl.exe to hide the unwanted console - perl programs always run under a console even if it's not visible.
jimhill
Expert User
 
Posts: 337
Joined: Sun Dec 19th, 2004 9:59pm
Location: UK

Re: Copy messages to automation

Postby Martin Clayton » Tue Sep 25th, 2007 8:49am

[aliases file]
jimhill wrote:Have you got an example of (part of) the problem handy? If so, perhaps you could post it to a new thread.

I'll put something on the dev mailing list tonight.

Jim Hill wrote:
Martin Clayton wrote:I've recently put together a tnef-decoder
Using Convert::TNEF, hopefully.

Yes, I really wanted it to work. ;-)

Jim Hill wrote:
Martin Clayton wrote:I'd appreciate your advice on the best way to invoke the monitoring script at boot-up when Mailtraq is running as a service.
You have a number of options ...

Thanks for the run down. I've started down the road with Win32::Daemon but hit a brick wall (possibly made of vista). If I don't crack it soon, I'll move to one of your alternative suggestions.

Cheers, Martin
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK


Return to Mailtraq Scripting

Who is online

Users browsing this forum: No registered users and 1 guest