Email Notification Script

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

Email Notification Script

Postby shiller1984 » Wed Mar 07th, 2012 6:26pm

We have a mailbox set up which we drop emails into via Outlook, there not sent to the mailbox just moved.

What I want to do is once an email is dropped in the mailbox I want it to send a notification to another user to tell them that it is there. The email will still have the users email address that it was originally sent to just moved to another mailslot.

I don't want to forward the email as it still needs to be accessed by everyone.

So I really want a simple one line email saying new message.

Is this possible, or am i going about it completely wrong.
shiller1984
 
Posts: 67
Joined: Sun Feb 07th, 2010 3:48pm

Re: Email Notification Script

Postby apurdam » Wed Mar 07th, 2012 10:43pm

I know you didn't want to forward the email, but...
A simple solution would be to set up the Mailbox Properties as follows:
In the Mail tab, check the box Send a copy of all incoming messages to and fill in the email address of your desired target,
and leave unchecked Delete from Mailbox.
I'm not sure what the Set Sender box does. My guess is that it changes the Sender to Mailbox address, which might be what you want (see musing about notification below).

That would send the whole message, but if it's on the same server, it would be nearly instantaneous.

I guess the only problem would be whether your recipient would know if it was a notification.

Hope this helps.
User avatar
apurdam
Expert User
 
Posts: 495
Joined: Thu Apr 19th, 2007 10:57pm
Location: Canberra

Re: Email Notification Script

Postby Elric Pedder » Thu Mar 08th, 2012 12:12am

shiller1984 wrote:We have a mailbox set up which we drop emails into via Outlook, there not sent to the mailbox just moved.

Do you drop emails using IMAP?
Mailtraq Development and Escalation Support
Novitraq Incorporated
User avatar
Elric Pedder
Mailtraq Escalation Support
 
Posts: 2675
Joined: Tue Nov 23rd, 2004 1:16pm
Location: Montreal, Canada

Re: Email Notification Script

Postby shiller1984 » Thu Mar 08th, 2012 6:00am

I know you didn't want to forward the email, but...
A simple solution would be to set up the Mailbox Properties as follows:
In the Mail tab, check the box Send a copy of all incoming messages to and fill in the email address of your desired target,
and leave unchecked Delete from Mailbox.
I'm not sure what the Set Sender box does. My guess is that it changes the Sender to Mailbox address, which might be what you want (see musing about notification below).

That would send the whole message, but if it's on the same server, it would be nearly instantaneous.

I guess the only problem would be whether your recipient would know if it was a notification.

Hope this helps.


Unfortunately these are large email that we do not want to keep forwarding between mailboxes.

Do you drop emails using IMAP?


Yes we do drop using imap
shiller1984
 
Posts: 67
Joined: Sun Feb 07th, 2010 3:48pm

Re: Email Notification Script

Postby Elric Pedder » Thu Mar 08th, 2012 1:02pm

shiller1984 wrote:
Do you drop emails using IMAP?

Yes we do drop using imap

I've added support for triggering the Storage scripts during IMAP APPEND in build 3154 which will be available today. As a result you can write a script which will execute when the message is stored in the mailbox, notifying another mailbox.

Here are the steps: create a new script named notifysave (in Options | Scripting and Templates | Scripts) with the following content, assuming that the mailbox you wish to monitor is "example" and the recipient you wish to notify is "user".

Code: Select all
<@LANGUAGE = Javascript@>
<%

  Server.MessageSend(
    "postmaster",   // sender
    "user",   // recipient
    "Subject: New Message has arrived\r\n",   // headers
    "A new message was posted to the example mailbox\r\n"  // body
  );
 
%>


Then in Automated Scripting create a new entry that will execute the new script, with a Mesage Trigger and in the Message Trigger tab set the filter to match "#rcpt" to the mailbox name, "example" and set Execute Script During to Message Storage.

notifyscript.png
Automated Script Settings
notifyscript.png (45.32 KiB) Viewed 13967 times
Mailtraq Development and Escalation Support
Novitraq Incorporated
User avatar
Elric Pedder
Mailtraq Escalation Support
 
Posts: 2675
Joined: Tue Nov 23rd, 2004 1:16pm
Location: Montreal, Canada

Re: Email Notification Script

Postby shiller1984 » Thu Mar 08th, 2012 6:20pm

Hi Elric

Many thanks for your help but it unfortunately did not work. :(

I have set up the script as you attached.

Changed the sender to my email, user to their email etc.

Put the Filter to #rcpt and EstimatingEnquiries as the match selected any.

but it did not send an email to the user?

looking at the server logs, when i moved from my inbox to the EstimatingEnquiries inbox it seems to "copy" not "append" not sure if this would make a difference

00040000 0000001A 08/03/2012 21:52:47 b3h8 LIST "" "INBOX/%" ---> b3h8 OK LIST completed (94ms)
00040000 0000001A 08/03/2012 21:52:48 67gx LIST "" "INBOX/%/%" ---> 67gx OK LIST completed (141ms)
00040000 0000001A 08/03/2012 21:52:48 tm5r LIST "" "INBOX/%" ---> tm5r OK LIST completed (94ms)
00040000 0000001A 08/03/2012 21:52:48 o7vd LIST "" "INBOX/%/%" ---> o7vd OK LIST completed (140ms)
00040000 0000001A 08/03/2012 21:52:49 9xz7 LIST "" "My Mailboxes/EstimatingEnquiries/INBOX/%" ---> 9xz7 OK LIST completed (94ms)
00040000 0000001A 08/03/2012 21:52:49 mbry LIST "" "My Mailboxes/EstimatingEnquiries/INBOX/%/%" ---> mbry OK LIST completed (94ms)
00040000 0000001A 08/03/2012 21:52:49 o28j LIST "" "My Mailboxes/EstimatingEnquiries/INBOX/Inputted/%" ---> o28j OK LIST completed (93ms)
00040000 0000001A 08/03/2012 21:52:50 roac LIST "" "My Mailboxes/EstimatingEnquiries/INBOX/Inputted/%/%" ---> roac OK LIST completed (94ms)
00040000 0000001A 08/03/2012 21:52:50 nn86 UID COPY 17765 "My Mailboxes/EstimatingEnquiries/INBOX" ---> nn86 OK [COPYUID 10 17765 515] COPY completed (31ms)
00040000 0000001A 08/03/2012 21:52:50 jawp UID STORE 17765 +FLAGS (\Deleted \Seen) ---> jawp OK STORE completed (0ms)
00040000 0000001A 08/03/2012 21:52:50 1v7g UID EXPUNGE 17765 ---> 1v7g OK EXPUNGE completed (0ms)
00040000 0000001A 08/03/2012 21:52:50 s3wy LIST "" "INBOX/%" ---> s3wy OK LIST completed (93ms)
00040000 0000001A 08/03/2012 21:52:51 u3v1 LIST "" "INBOX/%/%" ---> u3v1 OK LIST completed (140ms)


I believe the above covers the area of log that might be needed.

Thanks Simon
shiller1984
 
Posts: 67
Joined: Sun Feb 07th, 2010 3:48pm

Re: Email Notification Script

Postby Elric Pedder » Thu Mar 08th, 2012 10:15pm

shiller1984 wrote:looking at the server logs, when i moved from my inbox to the EstimatingEnquiries inbox it seems to "copy" not "append" not sure if this would make a difference

I didn't realise you were copying from one mailbox to another. Indeed the script is only triggered on the initial APPEND command. I have completed the necessary change to have the script trigger again on the COPY command in build 3156 but haven't had time to test it yet, if you care to give it a go.
Mailtraq Development and Escalation Support
Novitraq Incorporated
User avatar
Elric Pedder
Mailtraq Escalation Support
 
Posts: 2675
Joined: Tue Nov 23rd, 2004 1:16pm
Location: Montreal, Canada

Re: Email Notification Script

Postby Martin Clayton » Fri Mar 09th, 2012 6:12am

Elric Pedder wrote:Indeed the script is only triggered on the initial APPEND command. I have completed the necessary change to have the script trigger again on the COPY command...

Nice additions, Elric. I hope I'm not misreading ... I didn't realise that IMAP movements by-passed the Message Storage trigger. Now curious, does the same (still) apply to webmail? Does it also mean that the destination autoresponder is by-passed? (If not, perhaps this transport-neutral hook would be more reliable in this case).
User avatar
Martin Clayton
Expert User
 
Posts: 529
Joined: Sat Jan 15th, 2005 8:20am
Location: London, UK

Re: Email Notification Script

Postby Elric Pedder » Fri Mar 09th, 2012 5:45pm

Martin Clayton wrote:I didn't realise that IMAP movements by-passed the Message Storage trigger.

They do, or did, as they bypassed the router.

Martin Clayton wrote: Now curious, does the same (still) apply to webmail?

Webmail, in fact, has always gone through the router, even for Sent Mail and Drafts.

Martin Clayton wrote:Does it also mean that the destination autoresponder is by-passed?

The autoresponder is bypassed because the message isn't "delivered" with the router.
Mailtraq Development and Escalation Support
Novitraq Incorporated
User avatar
Elric Pedder
Mailtraq Escalation Support
 
Posts: 2675
Joined: Tue Nov 23rd, 2004 1:16pm
Location: Montreal, Canada

Re: Email Notification Script

Postby Martin Clayton » Sun Mar 11th, 2012 7:08am

Thanks for the pointers, Elric.
Elric Pedder wrote:Webmail, in fact, has always gone through the router, even for Sent Mail and Drafts.

I lost sight of the plumbing here but Mail activity process sorted it.
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

cron