1

Topic: Throttling one domain users

==== Required information ====
- iRedMail version (check /etc/iredmail-release):
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
======== Required information ====
- iRedMail version (check /etc/iredmail-release):  0.9.7
- Linux/BSD distribution name and version:  Debian 8
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):  LDAP
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Hi. Does throttling work when sending mail in one domain? E.g. from mail1@domain.com to mail2@domain.com.
When I send mail to the "outside" throttling works well, but for local domain ignores rules..

In throttle table I have the like following:

id: 1
account: @.
kind: outbound
priority: 0
period: 3600
msg_size: 1024
max_msgs: 0
max_quota: 0

id: 2
account: mail1@domain.com
kind: outbound
priority: 100
period: 3600
msg_size: 10240
max_msgs: -1
max_quota: -1

...

Is there a way to restrict message size for local mails?

----

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

2

Re: Throttling one domain users

Could you please try this patch for iRedAPD-2.2?
https://bitbucket.org/zhb/iredapd/commi … ad08d094b1

After applied the patch, you need to add line below in /opt/iredapd/settings.py and restart iredapd service:

THROTTLE_BYPASS_LOCAL_RECIPIENT = False

Please do let me know whether or not it works for you.

3

Re: Throttling one domain users

Hi. Sorry for late answer. My iRedAPD version is 2.1. My plugins/throttle.py: differs and I have the following in it:

    # Apply recipient throttling to smtp sessions without sasl_username
    if not kwargs['sasl_username']:
        logger.debug('Check recipient throttling.')
        action = apply_throttle(conn=conn,
                                user=recipient,
                                client_address=client_address,
                                protocol_state=protocol_state,
                                size=size,
                                recipient_count=recipient_count,
                                instance_id=instance_id,
                                is_sender_throttling=False)

        if not action.startswith('DUNNO'):
            return action
    else:
        logger.debug('Bypass recipient throttling (found sasl_username).')

    return SMTP_ACTIONS['default']

Is it ok if I replace it with the patch on git repo?

4

Re: Throttling one domain users

Please upgrade to iRedAPD-2.2 first, then apply the patch.

5

Re: Throttling one domain users

Hi. And sorry for late answer, again smile
I've upgraded to iRedAPD-2.2, applied patch. No result.
Enabled debugging said:

DEBUG SKIP: Sender domain (@domain.com) is same as recipient domain.
DEBUG <-- Result: DUNNO

I've digged into source and find below:

569    if sender_domain == recipient_domain:
570        logger.debug('SKIP: Sender domain (@%s) is same as recipient domain.' % sender_domain)
571        return SMTP_ACTIONS['default']

Little fix:

569    if sender_domain == recipient_domain and settings.THROTTLE_BYPASS_LOCAL_RECIPIENT:

Now, seems like it's working correctly. Will do some other test and let you know if any error occur

6

Re: Throttling one domain users

I think the original patch and your patch have different purposes.

For my patch: if email is sent by a local user, and recipient is also a local user (no matter sender domain is same as recipient domain or not), don't apply throttling for recipient. But throttling for this local sender is still applied.

For your extra patch: if sender and recipient in same domain, don't apply any throttling. (if you really need this, at least we need a new parameter for this control, "THROTTLE_BYPASS_LOCAL_RECIPIENT" is not good enough for this, we need a new one for your case, maybe "THROTTLE_BYPASS_SAME_DOMAIN".)

Also, please explain the logic behind your request: why do you need to throttle for email when sender and recipient are in same domain?

7

Re: Throttling one domain users

We have very poor bandwidth (less than 1Mbs) between head office (where mail server located) and some branch offices, which have about 40-60 users each. I don't want users to send large files by email (we have some supermind users who send video by email).
By the way, my patch works well for this purpose.

8

Re: Throttling one domain users

I updated iRedAPD and add a new parameter to control this:
https://bitbucket.org/zhb/iredapd/commi … b18a7464b1

New parameter THROTTLE_BYPASS_SAME_DOMAIN: if set to True, do not apply recipient throttling if both sender and recipient are in same domain. Defaults to True.

You should set it to False in your case, in /opt/iredapd/settings.py:

THROTTLE_BYPASS_SAME_DOMAIN = False

9

Re: Throttling one domain users

Great! Thanks!