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

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
User avatar
jimimaseye
Moderator
Moderator
Posts: 8580
Joined: 2011-09-08 17:48

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

Post by jimimaseye » 2015-05-26 12:46

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.
Attachments
LimitSMTP_script.2.3.1a.7z
(3.85 KiB) Downloaded 1165 times
Last edited by jimimaseye on 2015-06-26 19:42, edited 1 time in total.
5.7 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

crosemffet
Normal user
Normal user
Posts: 32
Joined: 2011-08-27 02:08

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

Post by crosemffet » 2016-07-14 17:03

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...?

User avatar
SorenR
Senior user
Senior user
Posts: 3576
Joined: 2006-08-21 15:38
Location: Denmark

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

Post by SorenR » 2016-07-14 17:22

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)
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

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

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

Post by jimimaseye » 2016-07-14 17:31

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.
5.7 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

kdiamond
Normal user
Normal user
Posts: 86
Joined: 2013-03-20 10:51

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

Post by kdiamond » 2018-03-23 16:46

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

Post Reply