MRatWork Forum by Mustafa Ramadhan

Sawo Project - Kloxo-MR Discussions => Kloxo-MR Tips and Tricks => Topic started by: chrisf on 2014-02-19, 08:41:30

Title: sendmail userid usage limits [script v1.1b]
Post by: chrisf on 2014-02-19, 08:41:30
This is a update and rewrite of the first script.  Please read:
http://forum.mratwork.com/kloxo-mr-tips-and-tricks/sendmail-userid-usage-limits-(script-v1-0b)/ (http://forum.mratwork.com/kloxo-mr-tips-and-tricks/sendmail-userid-usage-limits-(script-v1-0b)/)

The idea behind this update is no longer to send the mail piped line by line to the original sendmail.  Malformed email, or an extra carriage return/enter was causing the script to halt and not send.  To overcome this, I use a bash script to check with our database (OK to send mail) and then pipe it directly to the qmail sendmail program.  It gets it unaltered.  If a limit is reached, it simply doesn't pass it to the qmail sendmail.

This also made it faster, and under load, it performs better.  The logging has been changed, and can be either on or off.  It will log the time, working directory of the script which invoked it, user, user id, current count / Max count, and status.

If you already installed v1.0 you do not have to redo the SQL, but the configuration file and all else have changed.  Right before running the new install script, issue this command
Code: [Select]
rm -rf /usr/sbin/sendmailwrapper

Install is
Code: [Select]
cd /tmp
wget http://cc-server1.us/sendmail_wrapper20140219.zip
unzip sendmail_wrapper20140219.zip
./smw_install.sh

Log can be found at: /var/log/sendmail-limits.log and is rotated automatically daily, saving previous 10.

Read the txt file for details BEFORE running the install script, configuration is easy.  Again, report any issues.  This is a must for a shared hosting environment.

Enjoy!
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Spacedust on 2014-02-19, 22:20:58
Works well !!! Kloxo works fine, php scripts works fine. Fantastic job !
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: vpsbox on 2014-03-02, 15:54:33
this is major for everybody from free / payd host to personal vps on which site can be hacked on a user level and accout used as provy for spam... thnx
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Hugo on 2014-09-18, 17:31:15
Hello chrisf, I'm using your script and it works great, mails start to get dropped when the limit is reached and I get the notification e-mail, so thank you alot for this!

I am however not sure how to add users to the groups even after reading the instructions.

Could you provide an example of the configuration as such:

userA should belong to group 1
userB should belong to group 2

how would this look in the config file?

thanks again!
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Spacedust on 2014-09-21, 17:08:34
The hourly script stop working when many users send e-mail above limit:

Quote
[root@online stanislawbil]# /usr/sbin/sendmailwrapper/smw_cron_hourly
sendmail: fatal: file /etc/postfix/main.cf: parameter mail_owner: unknown user name value: postfix
Died at /usr/sbin/sendmailwrapper/smw_cron_hourly line 38.
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: chrisf on 2014-09-22, 18:03:11
@Asciiker - a new version will be released in a few weeks, a command line tool simplifies configuration.

@Spacedust, how many overages does it take?  I've had 80.  That line where it is exiting is for sending the email.  In the new version I have rewrote the send routines and will have you test to let me know.
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Spacedust on 2015-03-22, 17:37:18
Links are down. Please bring them back !
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Spacedust on 2015-07-30, 19:57:40
Bring it back !!!
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Spacedust on 2015-09-19, 11:44:37
These messages are looking wrong:

X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on xxx.pl X-Spam-Level:  X-Spam-Status: No, score=-0.0 required=5.0 tests=NO_RELAYS    autolearn=unavailable autolearn_force=no version=3.4.0 Delivered-To: xxx.pl-admin@xxx.pl Received: (qmail 18465 invoked by uid 0); 19 Sep 2015 08:00:01 -0000 Date: 19 Sep 2015 08:00:01 -0000 Message-ID: <20150919080001.18464.qmail@xxx.pl> From: root@xxx.pl Subject: Mail limit report To: admin@xxx.pl  The following clients have violated sender limits: (Hourly ~ groups 1 and 2)  1:gatek89:7812 (720/100) - 2015-09-19 09:56:23
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-10-05, 05:59:55
hello, it's 25 an hour or for 1 day?
is count in tables client_sendmail will reset for 1 hour or not?

because my client with > 25 cannot send email anymore before i reset count to 0

thanks
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-10-05, 06:22:48
my bad, i not set cron :D

thanks @chrisf for the great script
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: Spacedust on 2015-10-07, 20:06:06
chrisf can you add message body to these reports ?
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-11-28, 15:14:41
uhm... sorry for bother you guys.
but, i install the script at leaseweb cloud vps, and i got error (in folder /tmp):
Code: [Select]
-bash: ./smw_install.sh: Permission denied

can't you help me. please :D
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: MRatWork on 2015-11-28, 15:58:39
Permission of 'smw_install.sh' muat 755 or run with 'sh ./smw_install.sh'.
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-11-28, 16:34:53
Permission of 'smw_install.sh' muat 755 or run with 'sh ./smw_install.sh'.

works! thanks
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-11-30, 05:42:49
hello sorry to bother you again guys.

when my clients created email account for they domain and they use roundcube, in database i see user is "apache" not they username.

so if i have 5 clients, each of they create 3 email account, they belonging to the user "apache".

it's normal or not? thanks
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: MRatWork on 2015-11-30, 06:16:46
hello sorry to bother you again guys.

when my clients created email account for they domain and they use roundcube, in database i see user is "apache" not they username.

so if i have 5 clients, each of they create 3 email account, they belonging to the user "apache".

it's normal or not? thanks
Website for cp and webmail are under 'apache' user.
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-11-30, 06:57:30
when i change from roundcube to afterlogic, database sendmailwrapper not counting sent mail.
when i change it again to roundcube, it's counting again.

how to uninstall or not displayed webmail except roundcube?
so to limit and prevent spam, in my host webmail client is only roundcube (in this case i can limit it from user "apache").
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: MRatWork on 2015-11-30, 07:10:30
Go to 'webmail applications' and select 'roundcube'.
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: noob on 2015-11-30, 07:41:55
Go to 'webmail applications' and select 'roundcube'.

uhm.. my client will can change it again at "webmail applications menu".
i mean, the list of webmail applications only roundcube. is posibble?
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: MRatWork on 2015-11-30, 07:55:07
Need uninstall afterlogic with 'yum remove *afterlogic* -y; rm -rf /home/kloxo/webmail/afterlogic'.
Title: Re: sendmail userid usage limits [script v1.1b]
Post by: cikay on 2015-12-11, 04:27:25
Could you provide an example of the configuration as such:

userA should belong to group 1
userB should belong to group 2

how would this look in the config file?

thanks again!

yes i need it..i didn;t see in txt .. just

Clients in group...
1 can send 25 per hour
2 75 per hour
3 can send 300 per half day (12 hours)
4 500 per half day
5 can send 2000 per day (24 hours)
6 5000 per day

i only change this
# chrisf sendmail-wrapper v1.1b
5;

i dont know to add some user into another group, please help?