{% macro display_greylisting_setting(account, gl_setting) -%} {# @gl_setting is sql query result of per-account greylisting setting. #} {# Defaults to global setting: account == '@.' #} {% set account_type = 'global' %} {% set label = _('Greylisting service') %} {# Detect account type #} {% if account == '@.' %} {% set account_type = 'global' %} {% elif account.startswith('@') %} {% set account_type = 'domain' %} {% set label = _('Greylisting service for this domain') %} {% elif '@' in account %} {% set account_type = 'user' %} {% set label = _('Greylisting service for this user') %} {% endif %} {# is_greylisted: @None - Inherit global setting (no greylisting setting found) @True - Explicitly enabled @False - Explicitly disabled #} {% set is_greylisted = None %} {% if gl_setting.active == 1 %} {% set is_greylisted = True %} {% elif gl_setting.active == 0 %} {% set is_greylisted = False %} {% endif %}

{{ label }}

{% if account_type in ['domain', 'user'] %}
{{ _('Inherit global setting') }}

 

{% endif %}
{{ _('Enable greylisting service') }}

 

{{ _('Disable greylisting service') }}
{# About greylisting #}
{% endmacro %} {% macro display_greylisting_whitelist_domains(domains) -%}

{{ _('Do not apply greylisting on emails sent from domains listed below') }}

{{ _('One domain per line.') }} ({{ _('%d in total.') |format(domains |length) }})
  • {{ _('Server will NOT apply greylisting on IP addresses or networks specified in the SPF and MX DNS records of listed mail domains.') }}
{% endmacro %} {% macro display_greylisting_whitelists(account, gl_whitelists) -%}

{{ _('Do not apply greylisting on listed senders') }}

{{ _('One sender per line.') }}{% if gl_whitelists %} ({{ _('%d in total.') |format(gl_whitelists |length) }}){% endif %}

{{ _('Sender address format') }}

  • {{ _('IP Address') }}
    • {{ _('Single IP Address') }}: 192.168.2.10
    • {{ _('CIDR formatted range of IP addresses') }}: 192.168.2.0/24
  • {{ _('Email address or domain names') }}
    • {{ _('Single user') }}: user@example.com
    • {{ _('Entire domain') }}: @example.com
    • {{ _('All sub-domains') }}: @.example.com
  • {{ _('Record comment can be added after a #') }}: 192.168.2.20 # {{ _('Comment') }}
{% endmacro %} {% macro display_throttle_setting(account, setting, inout_type='inbound', with_left_border=false) -%} {# @inout_type: inbound, outbound #} {% if not setting %} {% set has_setting = false %} {% if account == '@.' %} {# Global setting #} {% set setting = {'period': 86400, 'priority': 0, 'max_msgs': 0, 'max_quota': 0, 'msg_size': 0, 'max_rcpts': 0} %} {% else %} {% set setting = {'period': 86400, 'priority': 0, 'max_msgs': -1, 'max_quota': -1, 'msg_size': -1, 'max_rcpts': -1} %} {% endif %} {% else %} {% set has_setting = true %} {% endif %} {% if with_left_border %}
{% else %}
{% endif %}
{% if inout_type == 'inbound' -%} {{ _('Throttle inbound mails') }} {% else %} {{ _('Throttle outbound mails') }} {% endif %} *
{% if setting.period in [86400, 3600, 60] %} {% set is_custom_period = false %} {% else %} {% set is_custom_period = true %} {% endif %}

{{ _('Period of time') }}*

{{ _('1 Day') }}
{{ _('1 Hour') }}
{{ _('1 Minute') }}
{{ _('Custom:') }} {{ _('Seconds') }}
{# max_msgs #} {% set is_custom_max_msgs = true %}
{% if inout_type == 'inbound' %}

{{ _('Number of max inbound emails') }}

{% else %}

{{ _('Number of max outbound emails') }}

{% endif %} {# 1: Unlimited 2: inherit from throttle setting which has lower priority 3: define explicit setting #} {% if account != '@.' %}
{% if account.startswith('@') %} {{ _('Inherit global throttle setting') }} {% else %} {{ _('Inherit per-domain throttle setting') }} {% endif %}
{% endif %}
{{ _('Unlimited') }}
{{ _('Custom:') }}
{# max_quota #} {% set is_custom_max_quota = true %}
{% if inout_type == 'inbound' %}

{{ _('Cumulative size of all inbound emails') }}

{% else %}

{{ _('Cumulative size of all outbound emails') }}

{% endif %} {% if account != '@.' %}
{{ _('Inherit from account which has lower priority') }}
{% endif %}
{{ _('Unlimited') }}
{{ _('Custom:') }} Bytes
{# msg_size #} {% set is_custom_msg_size = true %}

{{ _('Max size of single email') }}

{% if account != '@.' %}
{{ _('Inherit from account which has lower priority') }}
{% endif %}
{{ _('Unlimited') }}
{{ _('Custom:') }} Bytes
{# max_rcpts #} {% if inout_type == "outbound" %} {% set is_custom_max_rcpts = true %}

{{ _('Max recipients of single email') }}

{% if account != '@.' %}
{{ _('Inherit from account which has lower priority') }}
{% endif %}
{{ _('Unlimited') }}
{{ _('Custom:') }}
{% endif %}
{# col1-3 #} {% endmacro %} {# iRedAPD: wblist_rdns #} {% macro display_wblist_rdns(values, html_input_name, label, rows=10) -%}

{{ label |e }} ({{ _('One record per line.') }} {% if values %}{{ _('%d in total.') |format(values |length) }}{% endif %})

{% if values |length == 0 %} {% else %} {% endif %}
{%- endmacro %} {% macro display_wblist_rdns_formats() -%}
  • {{ _('Whitelist has higher priority than blacklist.') }}

{{ _('Valid record formats') }}

  • {{ _('Entire domain') }}: domain.tld
  • {{ _('Domain and its sub-domains') }}: .domain.tld

{{ _("This feature requires iRedAPD plugin 'wblist_rdns', please make sure it's enabled in file /opt/iredapd/settings.py.") }}

{# col1-3 #} {%- endmacro %} {% macro display_smtp_outbound_sessions(rows) -%} {% if rows %} {% for row in rows %} {% set sasl_username = row.get('sasl_username', '') |e %} {% set sender = row.get('sender', '') |e %} {% set recipient = row.get('recipient', '') |e %} {% set client_address = row.get('client_address', '') |e %} {% set encryption_protocol = row.get('encryption_protocol', '') |e %} {% endfor %} {% else %} {% endif %}
{{ _('Time') }} {{ _('Client Address') }} {{ _('Auth Username') }} {{ _('Envelope Sender') }} {{ _('Recipient') }} {{ _('Encryption Protocol') }}
{{ row['time'] | utc_to_timezone(timezone=session.get('timezone')) }} {{ client_address }} {{ sasl_username }} {{ sender }} {{ recipient }} {{ encryption_protocol }}
{{ _('No SMTP authentication activity.') }}
{%- endmacro %} {% macro display_smtp_sessions(rows, whitelisted_senderscore_ips=none, whitelisted_greylisting_ips=none) -%} {% if whitelisted_senderscore_ips is sameas none %} {% set whitelisted_senderscore_ips = [] %} {% endif %} {% if whitelisted_greylisting_ips is sameas none %} {% set whitelisted_greylisting_ips = [] %} {% endif %} {% if rows %} {% for row in rows %} {% set sasl_username = row.get('sasl_username', '') |e %} {% set sender = row.get('sender', '') |e %} {% set recipient = row.get('recipient', '') |e %} {% set client_address = row.get('client_address', '') |e %} {% set action = row.get('action', '') |e %} {% set reason = row.get('reason', '') | e %} {% set _is_senderscore = false %} {% set _is_greylisting = false %} {% set _is_whitelisted = false %} {% set _onclick_func = none %} {% if action == 'REJECT' and reason.startswith('Server IP address has bad reputation') %} {% set _is_senderscore = true %} {% set _onclick_func = 'whitelist_ip_for_senderscore' %} {% if client_address in whitelisted_senderscore_ips %} {% set _is_whitelisted = true %} {% endif %} {%- elif action == '451' and reason == '4.7.1 Intentional policy rejection, please try again later' -%} {% set _is_greylisting = true %} {% set _onclick_func = 'whitelist_ip_for_greylisting' %} {% if client_address in whitelisted_greylisting_ips %} {% set _is_whitelisted = true %} {% endif %} {% endif %} {% endfor %} {% else %} {% endif %}
{{ _('Time') }} {{ _('Client Address') }} {{ _('Auth Username') }} {{ _('Envelope Sender') }} {{ _('Recipient') }} {{ _('SMTP Action') }} {{ _('Rejection Reason') }}
{{ row['time'] | utc_to_timezone(timezone=session.get('timezone')) }} {{ client_address }} {% if session.get('is_global_admin') %} {% if _is_whitelisted %} {{ _('Whitelisted') }} {% elif _is_senderscore or _is_greylisting %} {# Display a button to whitelist this IP address. #} {{ _('Whitelist') }} {% endif %} {% endif %} {{ sasl_username }} {{ sender }} {{ recipient }} {%- if action == 'DUNNO' -%} {{ _('Dunno') }} {%- elif action == 'OK' -%} {{ _('Whitelisted') }} {%- else %} {% if _is_greylisting %} {{ _('Greylisted') }} {%- else -%} {{ action }} {%- endif -%} {%- endif -%} {% if action not in ['DUNNO', 'OK', '451'] %}{{ reason }}{% endif %}
{{ _('No matched SMTP sessions.') }}
{%- endmacro %} {% macro display_idtabs_of_smtp_sessions(activity) -%}
  • {{ _('All') }}
  • {{ _('Rejected') }}
  • {{ _('Outbound') }}
  • {%- endmacro %}