Page 1 of 1

Limit Outbound Mails by User, Domain or Server Average #2.3

Posted: 2015-05-26 12:46
by jimimaseye
Limit Outbound Mails by User, Domain or Server Average #2.3

(Taken from initial post viewtopic.php?p=151979#p151979. <<-- Find initial script and Manual here)

This attached script is a slightly modified version of the same script above but with a bug fix to allow for file locking on the 'control' files. For reference, it was provided by Soren from this post: viewtopic.php?p=175268#p175268

Refer to initial post (by 'Percepts', in brackets above) for instructions on use/the manual plus any problem solutions that may have already been covered.

Re: Limit Outbound Mails by User, Domain or Server Average #2.3

Posted: 2016-07-14 17:03
by crosemffet
ok, appreciate,
it looks exactly what I'm looking for.
the question is: how should I set the configuration values to let each user send a maximum of 10 mails per minute...?

Re: Limit Outbound Mails by User, Domain or Server Average #2.3

Posted: 2016-07-14 17:22
by SorenR
crosemffet wrote:ok, appreciate,
it looks exactly what I'm looking for.
the question is: how should I set the configuration values to let each user send a maximum of 10 mails per minute...?
If you poke around the links from above you'll most likely find this...

I take no credit for it, just saving your keyboard some finger grease...
'------------------------------------------------------------------
' SMTP limit outgoing emails of domain and user --- Manual
'------------------------------------------------------------------

1. Activate scripting in hmailserver: hm admin tool, settings->advanced->settings


2. Click on show scripts and open eventhandler.vbs


3a. in case you aren't using any vbs scripts at the moment
Paste the entire script into the the eventhandler.vbs file

3b. in case you are using vbs scripts
paste the global variables and settings section at the top of your script file
activate and/or integrated the provided content of sub OnAcceptMessage in your OnAcceptMessage
(just paste the provided content in your sub should do the trick)
paste the subs and functions below the sub OnAcceptMessage at the end of your script
(starts with the line sub check_outgoing_limitations(oClient, oMessage))

Advise: If you are already using automatic whitelisting, ensure the general functions don't exist twice!


4 do the settings (eventhandler.vbs)
ipslocalhost are the ips of the localhost separated by # from where you can send mails without authentification
user and pw is the login data to hmailserver
write_log_active is boolean and instructs the script to log the actions or not


'User and Domain outgoing limitation

outgoingstore is the file where the data is stored
outgoingexceptions here you can enter exceptions, will be created when first executed.
outgoingstoreavg internal file to store data
max_emails_per_user general limit for all users
max_emails_per_domain general limit for all domains
warning_factor warning factor, when the warning will be sent
server_average_days amount of days the script calculates the outbound average
server_average_threshold_factor threshold factor, how much the todays amount can be over the average
warning_factor_avg warning factor for average
msg_AdminName Admin Name (e.g. "Email Admin")
msg_AdminEmail Admin Email Address (e.g. "admin@admindomain.com")


5 save the files and close the editor


6 check syntax of the script in hm


7a syntax is correct -> reload the script in hm

7b syntax check fails -> check the error message an correct


8 Define individual limits for a user or a domain
File will be created the first time the script is executed.
@domain.com 1234 for domain limitations
a@b.com 5678 for user limitations
Instruction is also in the file.

9 check the event log and see if it works according to your testing
(this script writes writes to hmailserver_events.log in your hmailserver logs folder)

10 The hmailserver_events.log file needs to be cycled since there is no hmail inbuilt procedure for this. To do this setup a windows task scheduler job to run CycleEventLog.vbs (rename CycleEventLog.txt to CycleEventLog.vbs ) on a daily, weekly or monthly cycle according to which you prefer. (daily works best IMO)

Re: Limit Outbound Mails by User, Domain or Server Average #2.3

Posted: 2016-07-14 17:31
by jimimaseye
jimimaseye wrote: Refer to initial post (by 'Percepts', in brackets above) for instructions on use/the manual plus any problem solutions that may have already been covered.
Its almost as if it wasnt clear enough.

Re: Limit Outbound Mails by User, Domain or Server Average #2.3

Posted: 2018-03-23 16:46
by kdiamond
SorenR wrote:
2016-07-14 17:22
10 The hmailserver_events.log file needs to be cycled since there is no hmail inbuilt procedure for this. To do this setup a windows task scheduler job to run CycleEventLog.vbs (rename CycleEventLog.txt to CycleEventLog.vbs ) on a daily, weekly or monthly cycle according to which you prefer. (daily works best IMO)
Hi SorenR

Where do I get CycleEventLog.txt or CycleEventLog.vbs?

Another question
outboundstore.txt will store number of emails sent by the users and domains. Is this for the script functionality or just a log? Do I need to clear/delete it daily using task scheduler in order for the script to function on daily base?

Thank you for helping!

Br,
Dali