1

Topic: Global throttling with iredapd - Free version

==== Required information ====
- iRedMail version (check /etc/iredmail-release):  0.9.4
- Linux/BSD distribution name and version: CentOS 6.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx):Apache
- Manage mail accounts with iRedAdmin-Pro?: No, free version
- Related log if you're reporting an issue:
====

Requirement: Limit the mail sending for each account on the server to be 500 in 24 hours, Message size limit set to: 50mb

I Zhang's comments on the throttle.py file here: https://bitbucket.org/zhb/iredapd/src/d … hrottle.py

However I am not able to understand the syntax for global limit. Please provide some examples. Or create documentation if possible

   * msg_size: max size of single message
   * max_msgs: max number of sent messages
   * max_quota: max number of accumulated message size

What if I only want to set one of them?. Does '-1' mean unrestricted/unlimited?

Thank you
Abdul

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Global throttling with iredapd - Free version

The source file has some sample SQL commands. For example:

# Sample sender throttle settings:
#
# *) Allow user `user@domain.com` to send in 6 minutes (period=360):
#
#   * max size of single message is 10240000 bytes (msg_size)
#   * max 100 messages (max_msgs)
#   * max 4096000000 bytes (max_quota)
#
#  INSERT INTO throttle (account, kind, priority, period, msg_size, max_msgs, max_quota)
#                VALUES ('user@domain.com',
#                        'outbound',
#                        10,
#                        360,
#                        10240000,
#                        100,
#                        4096000000);
#
# Sample recipient throttle settings:
#
# *) Allow user 'user@domain.com' to receive in 6 minutes (period=360):
#
#   * max size of single message is 10240000 bytes (msg_size)
#   * max 100 messages (max_msgs)
#   * max 4096000000 bytes (max_quota)
#
#  INSERT INTO throttle (account, kind, priority, period, msg_size, max_msgs, max_quota)
#                VALUES ('user@domain.com',
#                        'inbound',
#                        10,
#                        360,
#                        10240000,
#                        100,
#                        4096000000);
#
abdulwahabkdi wrote:

What if I only want to set one of them?. Does '-1' mean unrestricted/unlimited?

Of course you don't need to set all of them. as mentioned in the source file:

# Valid values for throttle settings:
#
#  * XX (an integer number): explicit limit. e.g. 100. for example, set
#       `max_msgs=100` means user can send/receive up to 100 messages.
#  * 0: (explicit) unlimited.
#  * -1: inherit setting which has lower priority. for example, set
#       `msg_size=-1` for user `user@domain.com` will force iRedADP to check
#       `msg_size` setting in per-domain (`@domain.com`) and/or global (`@.`)
#       throttle settings.

3

Re: Global throttling with iredapd - Free version

Hi Zhang,

Thank you for your response.

I already tested a few, but not working


1. Want to limit 2 mails per 5 minutes globally for all accounts

INSERT INTO throttle (account, kind, priority, period, msg_size, max_msgs, max_quota) VALUES ('@.','outbound',10,5,0,2,0);

2.Want to limit user1@domain.com   2 mails per 5 minutes

INSERT INTO throttle (account, kind, priority, period, msg_size, max_msgs, max_quota) VALUES ('user1@domain.com','outbound',10,5,0,2,0);


However I was able to send more than 4 messages with in 5 five minutes. I did try restarting iredpad. Am I missing something?. Isn't how it supposed to work?

The above are just for testing purpose. My original goal is set limit of 500 mails per 24 hours with maximum mail size of 50MB, for all email accounts. globally.

Regards
Abdul

4

Re: Global throttling with iredapd - Free version

1) Priority of global setting is 0, not 10.
2) Priority of a single user is 100, not 10.

Please fix the priorities first, then try again. If it doesn't work, please turn on debug mode in iRedAPD, send testing email again, and copy the debug log here so that others can help troubleshoot.

Reference: http://www.iredmail.org/docs/debug.iredapd.html

Also, please show us output of commands below:

postconf smtpd_recipient_restrictions
postconf smtpd_end_of_data_restrictions

5

Re: Global throttling with iredapd - Free version

Hi Zhang,

Sorry about the priorities. I modified the "iredapd.throttle" table as below

INSERT INTO throttle (account, kind, priority, period, msg_size, max_msgs, max_quota) VALUES ('adam@cluster.example.com.au','outbound',100,5,0,2,0);

For testing i put a limit of 2 mails per five minute for the user adam@cluster.example.com.au

I see following in iredapd with out debugging on


================================
2016-04-26 21:42:49 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> max_msgs (0/2)
2016-04-26 21:42:49 INFO [127.0.0.1] RCPT, => adam@cluster.example.com.au -> postmaster@example.com.au, DUNNO
2016-04-26 21:42:49 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> msg_size (364/0)
2016-04-26 21:42:49 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> max_quota (0/0)
2016-04-26 21:42:49 INFO [127.0.0.1] END-OF-MESSAGE, => adam@cluster.example.com.au -> postmaster@example.com.au, DUNNO
2016-04-26 21:43:09 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> max_msgs (0/2)
2016-04-26 21:43:09 INFO [127.0.0.1] RCPT, => adam@cluster.example.com.au -> postmaster@example.com.au, DUNNO
2016-04-26 21:43:09 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> msg_size (364/0)
2016-04-26 21:43:09 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> max_quota (0/0)
2016-04-26 21:43:09 INFO [127.0.0.1] END-OF-MESSAGE, => adam@cluster.example.com.au -> postmaster@example.com.au, DUNNO
2016-04-26 21:43:25 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> max_msgs (0/2)
2016-04-26 21:43:25 INFO [127.0.0.1] RCPT, => adam@cluster.example.com.au -> postmaster@example.com.au, DUNNO
2016-04-26 21:43:25 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> msg_size (365/0)
2016-04-26 21:43:25 INFO [127.0.0.1] sender throttle, adam@cluster.example.com.au -> max_quota (0/0)
================================

I have atteched the iredapd log with debug on. I can see that there is following entries

2016-04-26 22:22:02 DEBUG Period of max_msgs expired, reset

I think the tracking is reset on every new mail.


Here is the postfconf output requested.


# postconf smtpd_recipient_restrictions
smtpd_recipient_restrictions = reject_unknown_recipient_domain    reject_non_fqdn_recipient    reject_unlisted_recipient    check_policy_service inet:127.0.0.1:7777    permit_mynetworks    permit_sasl_authenticated    reject_unauth_destination


# postconf smtpd_end_of_data_restrictions
smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:7777




Thanks
Abdul

6

Re: Global throttling with iredapd - Free version

abdulwahabkdi wrote:

INSERT INTO throttle (account, kind, priority, period, msg_size, max_msgs, max_quota) VALUES ('adam@cluster.example.com.au','outbound',100,5,0,2,0);

Why the period is 5 seconds? this is too short, and that's probably why the tracking record was reset evey new email.