specific mailbox rule is incorrectly applying to all mailboxes

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
path9898
New user
New user
Posts: 2
Joined: 2016-07-21 16:09

specific mailbox rule is incorrectly applying to all mailboxes

Post by path9898 » 2016-07-21 17:33

hello, I need to monitor the email that my young kids send and receive. I decided to do this by adding my email address to the messages as a BCC using this function in EventHandlers.vbs which I found in other forum posts

Sub OnAcceptMessage(oClient, oMessage)
oMessage.AddRecipient "me@domain.com", "me@domain.com"
oMessage.RefreshContent()
oMessage.Save
End Sub

and adding mailbox rules only on each of their mailboxes to run the function 'OnAcceptMessage'. This does exactly what i need (csend me a copy of all their emails) except that i am now also getting emails that were sent to other people on my server that have no mailbox rule specified. I don't get all of the mail for these other mailboxes, its completely random, i maybe get 10% of them. How do i fix this?

the log shows this for an unmonitored mailbox when it received a message even though no rule is specified:
"DEBUG" 2936 "2016-07-21 05:57:51.899" "Adding task AsynchronousTask to work queue Asynchronous task queue"
"DEBUG" 2712 "2016-07-21 05:57:51.899" "Executing task AsynchronousTask in work queue Asynchronous task queue"
"DEBUG" 2712 "2016-07-21 05:57:51.899" "Executing event OnAcceptMessage"
"DEBUG" 2712 "2016-07-21 05:57:51.899" "Event completed"
"DEBUG" 2712 "2016-07-21 05:57:51.899" "Saving message: {F994BA65-00E8-41FE-AF8F-E3F23B0BC256}.eml"
"DEBUG" 2712 "2016-07-21 05:57:51.914" "Requesting SMTPDeliveryManager to start message delivery"


is there a better way to get all the emails my kids receive AND send? getting what they receive is easy using a mailbox rule for all mail sent to them, but i could not figure out how to get a copy of what they send out. They use roundcube via IMAP to access their email

I am using hMailServer 5.6.5-B2367

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by percepts » 2016-07-21 17:53

just setup a global rule which says

To contains kid1@domain.com
OR
To contains kid2@domain.com
or
from contains kid1@domain.com
or
from contains kid2@domain.com

action forward email me@domain.com


your script will add you as recipient to every mail incoming and outgoing that passes through your server.
onAcceptMessage is fired for every incoming and outgoing message in hmailserver and you have not limited its action to specific email addresses.
Also you have refreshed the mail before saving it so you will possibly have undone your add recipients. Not sure about that.
Using a rule instead negates the need for bloat scripting

Also you shouldn't run onAcceptMessage from a rule. It runs automatically in the correct sequence/time of events as the message is processed by hmail. You may well add other stuff to that function not related to this and that would cause you problems down the line. If you want to use scripting for this (not necessary as it can be handled by a rule) then create a new fuction and call that from a rule. Just ad a new sub at end of eventhandlers.vbs and call it what you like.

Also if the rule you have setup is an account level rule it would only work on incoming mail to your kids accounts so it would need to be a global rule to catch outgoing email.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8116
Joined: 2011-09-08 17:48

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by jimimaseye » 2016-07-21 18:07

percepts wrote:just setup a global rule which says

To contains kid1@domain.com
OR
To contains kid2@domain.com
or
from contains kid1@domain.com
or
from contains kid2@domain.com

action forward email me@domain.com
You will also need to include the X-HMAILSERVER-LOOPCOUNT < 1 as the forwarded email will also be hit by the rule. That then makes things tricky (a OR b OR c AND D is not easy in rules). Remedy: 2 RULES - one for the FROM and one for the RECIPIENT LIST check (use RECIPIENT LIST instead of TO in case they are receiving addressed as a CC or BCC) using the method detailed in this HOW TO: viewtopic.php?f=21&t=29179
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

path9898
New user
New user
Posts: 2
Joined: 2016-07-21 16:09

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by path9898 » 2016-07-21 21:42

thanks for the info, I will make the changes and monitor

User avatar
jimimaseye
Moderator
Moderator
Posts: 8116
Joined: 2011-09-08 17:48

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by jimimaseye » 2016-07-21 21:45

FYI: Unrelated but in interests of protecting kids you might like this: viewtopic.php?f=20&t=29272
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 20103
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by mattg » 2016-07-21 23:48

I do exactly what you desire

Read this thread
viewtopic.php?f=9&t=17190

There is also a global rule testing FROM for each of my kids that forwards sent messages from my kids
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by percepts » 2016-07-22 03:01

you wait until the little darlings find out they can set up email accounts direct with other mail providers and bypass your hmailserver spying completely :lol:

User avatar
mattg
Moderator
Moderator
Posts: 20103
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by mattg » 2016-07-22 03:25

OpenDNS is a wonderful thing (just make sure that your mailserver doesn't use it!!)

On the router I send all DNS queries to OpenDNS and set a heap of filters limits, including webmail

Not foolproof, My girl at 8 worked out that she could access the school mail server from her home PC
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by percepts » 2016-07-22 08:21

OMG a geek at 8 years old, where will it end. :lol: :lol: :lol:

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: specific mailbox rule is incorrectly applying to all mailboxes

Post by percepts » 2016-07-22 18:02

this slight humour has a very serious side. I am reminded of someone I know who is an ofsted schools inspector in the UK. They also inspect private creche/kindergartens for toddlers. She did an inspection at a large american computer software company (Computer Associates) who ran a creche for employees kids about the age of 3 to 5 years old in the office premises so parents could bring their kids to work and not have to pay for child care.

She said it was a fantastic facility with top quality staff etc etc. Her only reason for marking the facility down was because there were precisely zero computers in the creche. It wouldn't ever have occurred to her that the software company knew what it was doing. That's the UK education system for you. They think you should plug a baby into a computer as soon as it pops out of the womb. This woman was completely hopeless with software applications. I think that older people who struggle with them think children will too. These teachers aren't smart enough to know that by and large PCs are time wasting devices that restrict creativity and free thinking to what the software allows which is often very limited.

My personal view is that schools shouldn't have computing of any kind on offer to kids until at least 16 years of age. If they want to have their own at home then by all means, but don't ram them down their throats from such a young age. The kids will become automatons only able to respond to software instructions.

Post Reply